Getting started with java script "math.random/floor"


#1


https://www.codecademy.com/courses/learn-javascript/lessons/introduction-to-javascript/exercises/random?action=lesson_resume


This is what the website instructions tell me when I ask for a "hint":
Math.floor(Math.random() * 100);
By placing Math.random() * 100 inside of the parentheses of Math.floor, we can make sure that the number generated will be a whole number. For instance, if Math.random() * 100 generated the number 64.65, Math.floor would make the result 64.
Note: Be careful of parentheses here. Each opening parentheses should have a closing parentheses.

This is the code that I inserted: Math.floor(Math.random() * 100);
Needless to say, I am consistently being told that code is incorrect. What exactly am I doing wrong?


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


#2

Hi @emurtha,

You forgot to complete the following step, the lesson says:

2.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.

You're required to print the number using console.log

Hint: ...??.... (Math.floor(Math.random() * 100));

:slight_smile:


#3

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