Creating elements in a loop in JavaScript

In the previous lessons, we created one new element. Let's now make it so that new elements are created in a loop.

For example, let's say we have a parent div like this:

html<div id="parent"></div>

Let's run a loop that adds 9 new paragraphs to the end of our div:

javascriptlet parent = document.querySelector('#parent');

for (let i = 1; i <= 9; i++) {
  let p = document.createElement('p');
  p.textContent = '!';
  
  parent.appendChild(p);
}
Задание 1

Given an empty ul. Run a loop that will insert 10 li tags into it. Make sure that the text of each li is its ordinal number.