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
Rishi B
13,866 Pointswhy this is not working ??
const odds = document.querySelectorAll('li'); odds.style.color = 'purple';
1 Answer
Matthew Dodd
Full Stack JavaScript Techdegree Graduate 16,657 PointsHey!
It won't work because 'odds' is an array of li's and you can't change the style to the collection in one step.
Instead, you could loop over the array of li's, select each one individually by using the index to access the odds array and then apply the style. Like so:
for(let i = 0; i < odds.length; i++){
odds[i].style.color = 'purple';
}
Rishi B
13,866 PointsRishi B
13,866 PointsThank you Matthew :)