Learn JavaScript: 6. Random HELP


<Below this line, add a link to the EXACT exercise that you are stuck at.>

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
It keeps saying ‘Expected an assignment or function call and instead saw an expression’
I even followed the hint exactly and it still isn’t letting me through.


Math.random() * 100

<do not remove the three backticks above>


just follow the instructions!

First Step:

1. Inside of a console.log, create a random number with Math.random, then multiply it by 100.
If you run the program few times, you’ll see random numbers in the console.

console.log(Math.random() * 100);

Second Step:

"Now, utilize Math.floor to make the output a whole number.
Inside the console.log you wrote in the last step, put Math.random() * 100 inside the parentheses of Math.floor."

console.log(Math.floor(Math.random() * 100));

And your problem is solved!

Please note the following:

  • Do not forget the semicolons!

  • The Math.random() function returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range.

  • The Math.floor() function returns the largest integer less than or equal to a given number.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.