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

JavaScript DOM Scripting By Example Editing and Filtering Names Fix DOM Manipulation Code

Kostatinos Yacoumakis
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Kostatinos Yacoumakis
Full Stack JavaScript Techdegree Graduate 16,231 Points

Can't get corresponding li to embolden.

I've tried many different approaches to this problem. The way I have it set right now is setting the const index to <= 2. That makes all list items bold when a number equal to and less than 2 is entered. I can't figure out how to get a list item to correspond to the number entered. What am I missing here?

1 Answer

Hey, we are looping through an array which contain all the li elements. the variable i represent each iteration of the loop. so all we need to do is check whether the variable i is equal to the index.

for example the user types 1 in the prompt, then the loop runs , the i = 0 and the index = 1, the condition isn’t true so the item isn’t bolded. then we are on the second iteration, i= 1 and the index is 1 so the condition is met and the specified li element get bolded.

i hope this was clear enough