Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
why use [i] so many times
I don't understand the logic in this case. Wouldn't be enough calling [i] for the list items only once when we start the event Listener? Why do we have to specify [i] inside the function as well?
Steven Parker228,991 Points
A number in braces is an index and does not "call" a function or method as you would with parentheses. And it's a very efficient operation.
It's very common for a loop to establish an index variable (often named "i") which is then used throughout the body code of the loop to access a specific member item in a collection, as is done with the list items in the video example.