Random


#1


I need help with 8/9 exercise

https://www.codecademy.com/en/courses/learn-javascript/lessons/control-flow/exercises/random


My code is like this: Math.floor(Math.random() * 100);


The error message I keep getting is:  Do the parentheses of Math.floor() wrap around the Math.random() * 100 expression?

Thanks so much for your great help!


#2

HI in your code

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

you didn't close Math.floor() it's missing the closing )


#3

Are you sure? Looks fine to me..


#4

@jibblyj My bad :grimacing:
@lavincreative can you post all your code?


#5

The requirement of the exercise says:
Put randomNumber's value inside the parentheses of Math.floor().

So my code is like this:
var randomNumber = Math.random() * 100;
console.log(randomNumber);
Math.floor(Math.random() * 100);


#6

This line

var randomNumber = Math.random() * 100;

like the error says..
Do the parentheses of Math.floor() wrap around the Math.random() * 100 expression?
it's on this line that you should put the Math.random() * 100 inside Math.random()
then remove this line (the last line)

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

#7

How can I remove the last line? It asks me to use Math.floor().


#8

YOu shoudl use Math.flo.. on this line

var randomNumber = Math.random() * 100;

put it around Math.random() * 100


#9

I see. Thank you sooo very much. Now it works. Really appreciate your help.


#10

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