JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Create a while Loop

Robert O'Toole
Robert O'Toole
6,323 Points


it seems that for some questions if i want the loop to run 28 times this works:


then other times this works:


why is that? im still making sure to put the count +=1 and var count=0

can someone plz explain this? the past few quizzes seem to give me different reasons why code isnt working and to my knowledge it seems rather inconsistent :/

54,192 Points

Can you provide complete code loop examples?

1 Answer

Armin Kadic
Armin Kadic
12,653 Points

Because if you only put a greater than sign ">" or less than "<" sign, the number you provided will not be included. So if you write "count < 26" this will make it count to 26 but not including 26. On the other hand, if you add an equal sign like this "count <= 26" , this will include the 26. The count starts from zero, so this "count <= 26" will count 27 times because it includes the zero and the number 26. This "count < 26" will count it 26 times because it gets the zero but not including the 26. I hope this clears things up for you :)