Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

1 Answer

I hope I am understanding your question correctly. Did you mean: "Why is the textContent on both sides of the equals sign?"? After watching the video, I believe you are referencing this line of code:

listItems[i].textContent = listItems[i].textContent.toUpperCase()

This function:

listItems[i].textContent.toUpperCase()

Only RETURNS the uppercase value of whatever listItems[i].textContent happens to be on that iteration. This alone:

listItems[i].textContent.toUpperCase()

does not change listItems[i].textContent itself. The only way to achieve a persisting modification of the listItems[i].textContent text is to reassign the modified textContent back to itself, which is what this line of code it doing:

listItems[i].textContent = listItems[i].textContent.toUpperCase()

Is that what you meant? Anyway, I hope that helps. Happy coding!