Math.floor


#1

When doing the Math.random and Math.floor script im not able to figure it out.

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.

so, the first one should be console.log(Math.random() * 100);

gives me the result 48.35

2.
Now, utilize Math.floor to make the output a whole number.

so it should be console.log(Math.floor(48.35) * 100);

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

im stuck, i dont know what is the correct answer.


#2

here:

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

this will generate a different number every time:

for (var i = 0; i < 10; i++){
    console.log(Math.random() * 100);
}

we want to floor any random number generated by math.random, not just the first generated random number


#3

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