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 A Closer Look at Loop Conditions

Uncaught SyntaxError: missing ) after argument list

I've been having problems making the "Let's make random numbers" project. I have checked my code with the one in the video several times but I couldn't find the problem so then I checked the console and apparently I have a syntax error on line 15. I would be very grateful for any help and advice that you can give me.

Here's what my code looks like:

var upper = 10000;
var randomNumber = getRandomNumber(upper);
var guess;
var attempts = 0;

function getRandomNumber(upper) {
  return Math.floor( Math.random() * upper ) + 1;
}

while ( guess !== randomNumber ){
  guess = getRandomNumber( upper );
  attempts += 1;
}

document.write("<p>The random number was: " + randomNumber "<p>");
document.write("</p>It took the computer " + attempts + " attempts to get it right.</p>");

1 Answer

Tobias Helmrich
Tobias Helmrich
31,602 Points

Hey Basia,

your code is almost right. You're just missing a + here:

document.write("The random number was: " + randomNumber "");

After randomNumber you should write a + to concatenate the string (even though there's nothing in it right now so you might want to add a point or something like this).

So if you replace this with that:

document.write("The random number was: " + randomNumber + ".");

it should work. I hope that helps, good luck! :)

Thank you very much!

Tobias Helmrich
Tobias Helmrich
31,602 Points

No problem, I'm glad I could help! :)