Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Create a while Loop

I keep getting a syntax error: parse error. I'm not sure what is wrong with my parameters.

I keep getting a parse error, so I googled what this meant and it said that something in my parameters is not being understood by JavaScript, but I am using a parameter we have been using in multiple examples, so I am not sure what it wrong with it.

script.js
function randomNumber(upper){
return Math.floor(Math.random()*upper)+1;
}

let count = 0;
while(count < 26){
let randomNum = randomNumber(26);
  document.write(randomNum+'')

  count += 1;
}

2 Answers

Micah Hobbs
seal-mask
.a{fill-rule:evenodd;}techdegree
Micah Hobbs
Python Development Techdegree Student 13,066 Points

Hey Karly

The code runs without any errors in my browser console (prints out 26).

Is the error actually associated with this chunk of code? Which line in particular gives you the syntax error: parse error?

Hey Karly, There is nothing really wrong with your code, meaning that technically it is syntactically correct. However you are missing a semicolon after your document.write statement. But the real problem is that this challenge doesn't appear to like it if you use let instead of var.