Hi,
I’m trying to understand .length in a for loop. The list here ‘li’ has 5 items by the way.
Question 1: In this case, is liEven.length equal to 2 since there are 2 even items?
Question 2: if that’s the case, does that mean the loop will only run 1 time? (since i < liEven.length which is 2)
const liEven = document.querySelectorAll('li:nth-child(even)');
for(let i = 0; i < liEven.length; i ++){
liEven[i].style.background = 'green';
}
Thank you for your help!