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 trialDaniel Williams
Courses Plus Student 1,325 PointsRun 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
var count = 0;
while (0<=26){
document.write(count);
count += 1;
}
3 Answers
Michel Näslund
18,583 PointsCode 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
22,989 PointsYou'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!
Daniel Williams
Courses Plus Student 1,325 PointsI Have altered the code a little bit but it still tells me that the code took too long to run
Logan R
22,989 PointsDid you replace the 0
with the count
variable? What does your code look like now?
Daniel Williams
Courses Plus Student 1,325 PointsI replaced the 0 with 1 but still it reads out to me "Bumper, your code takes too long to run"