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 trialanalyn jane calado
3,523 PointsI'm stuck here!
please, i need your suggestions.
var counter = 1;
while (10) {
document.write("<p>#10" + counter + "</p>");
counter += 1;
}
Colin Marshall
32,861 PointsDid you check out my answer below? It's telling you your code took too long to run because you have an infinite loop in your code. The Treehouse code that checks your answer has a feature that will detect infinite loops and give you that error message.
1 Answer
Colin Marshall
32,861 PointsYou have while (10)
which is only testing if 10 is true
or false
. Integers will always return true so your loop will repeat forever. You need to have the loop check to see if the counter variable is less than or equal to 10 so that the loop quits when the counter is more than 10.
var counter = 1;
while (counter <= 10) {
document.write("<p>#10" + counter + "</p>");
counter += 1;
}
analyn jane calado
3,523 Pointsoh!!! yeah.. it worked! hhmm, thank you so much.!
analyn jane calado
3,523 Pointsanalyn jane calado
3,523 Pointsbut it says there, Your code took too long to run.