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 Numbers The Math Object Random Number Challenge – Two Numbers Solution

Geoffrey Burkholder
seal-mask
.a{fill-rule:evenodd;}techdegree
Geoffrey Burkholder
Full Stack JavaScript Techdegree Student 1,881 Points

Unexpected token--- Its the semicolon

Hello everyone! i am currently stuck on a coding challenge due to a semi colon issue. After doing some research i believe i am using a greek question mark instead of a semi colon. apparently they extremely similar if not the same. Any body have any ideas of what to do?

// Collect input from a user
const userNumberLow = prompt('Choose a low number!');
const userNumberHigh = prompt('Now choose a high number!');
// Convert the input to a number

const topPNumber = parseInt(Math.floor(userNumberHigh)); //P- The top possible number
const topBNumber = parseInt(Math.floor(userNumberLow)); //B- The bottom lowest possible number

// Use Math.random() and the user's number to generate a random number



// Create a message displaying the random number

if (topBNumber && topPNumber) {

>  const theRandomNumber = (Math.floor(Math.random() * (topPNumber + topBNumber + 1)) + topBNumber;

  alert(`${theRandomNumber} is a random number between ${topBNumber} and ${topPNumber}!`);

  console.log(theRandomNumber);

} else {alert ('You did not pick two number's, please try again.')}

1 Answer

In the line const theRandomNumber = (Math.floor(Math.random() * (topPNumber + topBNumber + 1)) + topBNumber;, there are 4 ( and 3 ). Try adding a ) before the ;.

Semicolons in JavaScript are usually optional. If you have problems typing them, you could try leaving them out.