This loop is supposed to add 5 list items, but its condition stops it one item short. Fix the loop condition.
Acceptance criteria
- 1.The list should have 5 items.
- 2.The fifth item should read "Item 5".
This loop is supposed to add 5 list items, but its condition stops it one item short. Fix the loop condition.
const list = document.getElementById('list'); for (let i = 1; i <= 4; i++) { const item = document.createElement('li'); item.textContent = 'Item ' + i; list.appendChild(item); }
Output ready when you are
Press Run to render your code, or Submit to validate your solution.