CSS Comprehension test

by nickm49

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <title>Loops: Task 1</title>
    <style>
      p {
        color: purple;
        margin: 0.5em 0;
      }

      * {
        box-sizing: border-box;
      }
    </style>
    <link rel="stylesheet" href="../styles.css" />
  </head>

  <body>

    <section class="preview">



    </section>

  </body>
  <script>

    const myArray = ['tomatoes', 'chick peas', 'onions', 'rice', 'black beans'];
    const list = document.createElement('ul');
    const item = document.createElement('li');
    

    for(const food of myArray){

    list.appendChild(item);
    item.textContent = food;
}

    // Don't edit the code below here!

    const section = document.querySelector('section');
    section.appendChild(list);



  </script>

</html>