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

Run while loop 26 times

I keep getting that it takes too long to run and I want to be sure that I have the code right

script.js
var count = 0;
while (0<=26){

document.write(count);
count += 1;  
} 

3 Answers

Michel Näslund
Michel Näslund
18,583 Points

Code below passes the test.

Your code runs 27 times because you are using the operator <= ("smaller or equal").

var count = 0;
while (count<26){

document.write(count);
count += 1; 
} 
Logan R
Logan R
22,989 Points

You've almost got it! The issue is your while loop. Right now you are doing while (0 <= 26). The issue with this is that both 0 and 26 never change. You'll want to change the zero to a variable that you are constantly updating in the while loop.

Hope this helps!

I Have altered the code a little bit but it still tells me that the code took too long to run

Logan R
Logan R
22,989 Points

Did you replace the 0 with the count variable? What does your code look like now?

I replaced the 0 with 1 but still it reads out to me "Bumper, your code takes too long to run"