Source Code:
(back to article)
Submit
Result:
Report an issue
<body></body> <script> // Creating the list container let list = document.createElement('ul'); document.body.appendChild(list); // Adding items to the list function addItem(text) { let item = document.createElement('li'); item.textContent = text; list.appendChild(item); } addItem('Learn JavaScript'); addItem('Build a to-do list'); </script>