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