World Factbook: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 7: | Line 7: | ||
.then((r)=>{ | .then((r)=>{ | ||
let letters = r.map(c=>c.name[0]); | let letters = r.map(c=>c.name[0]); | ||
for(let a | for(let a of letters){ | ||
let b = document.createElement('button'); | let b = document.createElement('button'); | ||
b.innerText = a; | b.innerText = a; | ||
Line 19: | Line 19: | ||
.then((r)=>{ | .then((r)=>{ | ||
let letters = r.map(c=>c.name[0]); | let letters = r.map(c=>c.name[0]); | ||
for(let a | for(let a of letters){ | ||
let b = document.createElement('button'); | let b = document.createElement('button'); | ||
b.innerText = a; | b.innerText = a; |
Revision as of 09:22, 22 January 2022
1) Get a button for each letter
Input
xxxxxxxxxx
fetch('/worldl.json')
.then((r)=>r.json())
.then((r)=>{
let letters = r.map(c=>c.name[0]);
for(let a of letters){
let b = document.createElement('button');
b.innerText = a;
document.body.append(b);
}
});
Output
fetch('/worldl.json') .then((r)=>r.json()) .then((r)=>{ let letters = r.map(c=>c.name[0]); for(let a of letters){ let b = document.createElement('button'); b.innerText = a; document.body.append(b); } });
fetch('/worldl.json') .then((r)=>r.json()) .then((r)=>{ let letters = r.map(c=>c.name[0]); for(let a of letters){ let b = document.createElement('button'); b.innerText = a; document.body.append(b); } });