DOM content from lists
Show a list of numbers
- When you have data in a list you can use a for loop to generate content
fetch('/beatles.json') .then((r)=>r.json()) .then((r)=>{ for(let beatle of r.members){ let div = document.createElement('div'); div.innerHTML = beatle.firstName; document.obdy.append(div); } });
for(let beatle of ['John', 'Paul', 'George', 'Ringo']){ let div = document.createElement('div'); div.innerHTML = beatle; document.body.append(div); }