For loop with condition = number

So, I am trying to learn how to use for loops in this exercise: [], but while I was trying to figure it out, I typed:

for (let counter = 5; counter =11; counter++) { console.log(counter); }

When I ran it, it printed the number 11 a lot of times. However, the counter was set to start from 5 and there was no 5 in the console. So, because 5 is not equal to 11, shouldn’t the loop evaluate false and stop?

Hey @fakefoilnumber1 welcome back to the forums.

You are doing counter = 11 and a single equal sing is assignment and not comparison. stetim94 does a better job explaining.

Thanks so much for the help! That got me really confused and couldn’t figure it out on my own…

1 Like