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 Basics (Retired) Working With Numbers The Random Challenge Solution

Bence Szabó
Bence Szabó
5,885 Points

Workspaces doesn't work

Hello!

I tried your version, but my browser doesn't respond to it. When I open the console log it says: Uncaught SyntaxError: Unexpected string random.js:4

the line is:

var message = "<p>" + randomNumber + " is a number number between 1 and " + topNumber. "</p>";

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Bence,

Firstly, I've fixed your code formatting which you can learn more about at the below link.

https://teamtreehouse.com/forum/posting-code-to-the-forum

As for the problem at hand, there is a minor syntax error in the JavaScript after topNumber which is there's a period after the variable declaration instead of a plus symbol which is invalid syntax.

var message = "<p>" + randomNumber + " is a number number between 1 and " + topNumber + "</p>";

Dave McFarland, one for you you to look into :wink:

Happy coding!

Bence Szabó
Bence Szabó
5,885 Points

Yay!

Thank you very much! It's a bit late but a treaky SyntaxError never sleeps :)