Karan Sheth2,431 Points
Why use a for loop instead of selecting the entire tag list?
Why do we have to iterate through the list of Li tags using a for loop to make them purple? Why can't we directly assign the color purple to myList itself?
myList.style.color = 'purple';
Why doesn't the above code work?
Jamie ReardonTreehouse Project Reviewer
Because it is an HTMLCollection that is an array-like element. In plain English, it doesn't work because you are trying to style the array.
That is why you use a for loop to iterate through the array to style the individual li elements. Without the loop, you would be tediously repeating code.