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 corson
Full Stack JavaScript Techdegree Student 1,783 PointsWhat is the answer to this question ?!!
I am adding 1 < = 10 in the parenthesis of my while loop and it is not being accepted :( No hint, and related questions are ALL over the fourms, seriously people?!
var counter = 1;
while ( ) {
document.write("<p>Now in loop #" + counter + "</p>");
counter += 1;
}
2 Answers
Steven Parker
231,275 PointsThe "while" needs an expression inside the parentheses to evaluate to determine whether to continue or not.
You probably want to compare "counter" with some value.
I'll bet you can get it now without an explicit code spoiler.
kim corson
Full Stack JavaScript Techdegree Student 1,783 PointsI know lol, thank you! I was very tired and I figured it out like 2 minutes later XD
Richard Pichardo
14,851 PointsYour code inside the parenthesis should be:
while (counter <= 10)
As every time you run through the loop counter will be incremented by one and the condition will be checked against counter. Setting the condition as you have at the moment will cause an infinite loop as 1 will always be less than 10 and is never incremented.
If I am mistaken, please let me know.
kim corson
Full Stack JavaScript Techdegree Student 1,783 PointsLol thank you! I asked the question before giving myself some time to figure it out. I got it! You are awesome! Thank you for answering my question. :)
kim corson
Full Stack JavaScript Techdegree Student 1,783 Pointskim corson
Full Stack JavaScript Techdegree Student 1,783 Pointsoh by the way, the quiz requirement is to get the code to run 10 times