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()

Aakash Srivastav
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,625 Points

Listening for events with addEventListener()

This is my third question related to this video.
Now my question is , why doesn't he used the "style" property to make the letter uppercase, as he did in the other videos.
As he said , in order to change the css of any elements we use "style" property.
In this case it will go like this:

for( let i = 0 ; i < listItems.length ; i+=1){
    listItems[i].addEventListener( 'mouseover' , () => {

        listItems[i].style.textTransform = "uppercase";     // used "style" property      

    listItems[i].addEventListener( 'mouseout' , () => {

        listItems[i].style.textTransform= "uppercase";  // used "style property     

Is there any specific reason that he didn't used this method?

1 Answer

Daniel Hernandez
Daniel Hernandez
13,437 Points

I believe he used a different convention just to teach different ways of doing the same thing. I don't personally know the advantages over one method from the other, so I expect it is just a difference in method.