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 trialKim Dallas
11,461 Pointswhy is it taking too long?
why is it taking too long to run? is it an endless loop? I don't understand what I'm missing
var count = 0;
while (count < 26) {
document.write;
}
1 Answer
Nick Hericks
Full Stack JavaScript Techdegree Graduate 20,704 PointsHi Kim! You are correct in your assumption that the way it written above, this is indeed an endless loop. Right now your condition is (count < 26)
which is actually saying "as long as the count variable is less than 26, keep looping."
To prevent this from looping forever, you will need to add an iterator inside the loop that increases the count variable. Here's one way to add an iterator inside this loop:
var count = 0;
while (count < 26) {
document.write();
count = count + 1;
}
You could also write the iterator like this which does the same thing:
var count = 0;
while (count < 26) {
document.write();
count++;
}
Also note that document.write() is a method so you'll need to include the () at the end. That is missing in the above code. After making those small changes, you should be passing with flying colors!!!
Hope this helps! Keep on coding!
Kim Dallas
11,461 PointsKim Dallas
11,461 Pointsthank you