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 trialAndrew Nicholson
2,474 PointsMy code took too long to run (??)
Is this because my code is wrong or because my internet speed is horrendous?
var count = 0;
while ( count < 26 ) {
document.write( count + " ");
}
2 Answers
Dan Johnson
40,533 PointsYou forgot to update count in the while loop, so count < 26
will always evaluate to true
, locking the program in an infinite loop.
Jonathan Grieve
Treehouse Moderator 91,253 PointsYup, the loop needs a way to break out. You need a way of changing the value in the code so that eventually the while condition will be false ensuring the loop will end!. :-)
Andrew Nicholson
2,474 PointsAndrew Nicholson
2,474 Pointsah very good! I couldn't for the life of me work out if there was something missing or not. Code blind!
Thanks