DOM content from lists

From ProgZoo
Jump to navigation Jump to search

Show a list of numbers

  • When you have data in a list you can use a for loop to generate content
for(let beatle of ['John", 'Paul', 'George', 'Ringo']){
  let div = document.createElementById('div');
  div.innerHTML = beatle;
  document.body.append(div);
}
for(let beatle of ['John', 'Paul', 'George', 'Ringo']){
  let div = document.createElement('div');
  div.innerHTML = beatle;
  document.body.append(div);
}