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 trial

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.