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 trial3 Answers
Shawn Flanigan
Courses Plus Student 15,815 PointsHi Fang-Wen,
Remember you'll need to increase your count variable every time you run the loop...otherwise your condition (count < 26) will always be true and the loop will run infinitely.
Shawn Flanigan
Courses Plus Student 15,815 PointsSo...simply add count++; after document.write("poo"); and you should be golden.
Jennifer Nordell
Treehouse TeacherHi there! While your code doesn't generate any errors, it does result in an infinite loop. You never alter the value of count
so it will always be less than 26.
If I add an increment to count below your document.write
, the challenge passes:
count++;
Hope this helps!
Steven Parker
231,248 PointsIf it was "correct code" then it would work.
The problem in this case is that you don't change the count value inside the loop. So the condition being tested by the while
is always true and the loop never stops.
The easiest fix would be to increment or add one to the count in the body of the loop.
And remember that what makes code "correct" is more than just having no errors. It must also do the right thing.
Abraham Juliot
47,353 PointsAbraham Juliot
47,353 PointsLOL "my correct code wont work"
Well, you wrote a program to fail correctly