World Factbook

From ProgZoo
Jump to navigation Jump to search

Get a button for each letter

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 = new Set(r.map(c=>c.name[0]));
     for(let a of letters){
       let b = document.createElement('button');
       b.innerText = a;
       document.body.append(b);
     }
  });