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

Kostatinos Yacoumakis
Kostatinos Yacoumakis
Full Stack JavaScript Techdegree Student 9,099 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