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 trialKristenia Clark
2,252 PointsI'm getting Syntax error over and over again. What did I miss?
I have Syntax Error but I'm unable to see where I'm doing wrong
var count = 0;
while ( counter < 26 ) {
var count = randomNumber(6);
document.write ( randNum + ' ' );
counter + = 1;
}
2 Answers
Jamie Reardon
Treehouse Project ReviewerYou have no variable named counter, only count. You need to change where it says counter to count and remove the var keyword from the while loop code block.
Unsubscribed User
15,201 PointsHi Clark,
Because you are using different variables, you just need to use one variable "count".
var count = 0;
while ( counter < 26 ) { /* The variable counter doesn't exist, so the while loop doesn't know if the value is less than 26 */
var count = randomNumber(6); /* You don't need this */
document.write ( randNum + ' ' ); /* Same here, randNum doesn't exist */
counter + = 1; /* Pay attention here, there is space between + and = */
}
The challenge is asking to print the variable until it reaches 26 through a while loop.
var count = 0; /* Set value 0 */
while ( count < 26 ) { /* Set the condition for the loop "Count until count is 26" */
document.write (count); /* Print the value of count */
count += 1; /* Increment of 1 the value */
/* When the value reach 26 the loop will stop */
}
I hope this will help you :)