JavaScript JavaScript and the DOM Responding to User Interaction Listening for Events with addEventListener()

Eric Peppler
Eric Peppler
3,599 Points

Copying his code exactly results in error...?

const listItems = document.getElementsByTagName('li');

for (let i = 0; i < listItems.length; i++) {
    console.log(`In Loop: ${i}`);
    listItems[i].addEventListener('mouseover', () => {
                               listItems[i].textContent = listItems[i].textContent.toUpperCase();
                               });
    listItems.addEventListener('mouseout', () => {
                               listItems[i].textContent = listItems[i].textContent.toLowerCase();
                               });
}

Error: Uncaught TypeError: listItems.addEventListener is not a function

Really stuck here....help please

edit: forgot [i] in one place.....nevermind!