In this scenario, we are looking for a list of elements gathered in one variable - rather than only one element. Assign the list items in the view to the variable 'listItems' by using an appropriate selector method.Once you have completed the code below, verify it by hovering over the list items until all items have the value 'ON'

HTML snippet

<ul id="list">
<li>OFF</li>
<li>OFF</li>
<li>OFF</li>
<li>OFF</li>
<li>OFF</li>
<li>OFF</li>
</ul>

JavaScript snippet

const listItems = document.querySelectorAll('#list li');

for (let i = 0; i < listItems.length; i++) {
  listItems[i].addEventListener('click', () => {
    // complete the code snippet
  });
}
	

Preview

Screenshot 2025-04-17 120404.png