Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Robert O'Toole
Robert O'Toole
6,366 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 :/

Can you provide complete code loop examples?

1 Answer

Armin Kadic
Armin Kadic
16,242 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 :)