Question about 'Libraries'


#1

Hello :raised_hand_with_fingers_splayed:, I am a student learning JavaScript, and I would be appreciated if you help me with this question, please.
It is in chapter ‘Libraries’ in Introduction to JavaScript.

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

The instruction is

  1. Inside of a console.log, create a random number with Math.random, then multiply it by 100.

I did it well until here, with this:

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

BUT
I don’t know how should I do with this instruction:

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

There’s always an error when I try it.
I am totally stuck on this part.
Can you help me, please?
Thanks!


#2

What is the error message?

can you also share exercise url so we can quickly access the exercise?

console.log(Math.floor(Math.random() * 100)); looks right, what code are you running that produces an error message?

@gpdms2210, no need to make two identical topics.


#3

Thanks for quick reply.
The url is
https://www.codecademy.com/courses/learn-javascript-introduction/lessons/introduction-to-javascript/exercises/libraries?action=lesson_resume&course_redirect=introduction-to-javascript
and the code

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

seems to have an error.
Once again, thanks!


#4

i reset the exercise, ran your code, and everything pans out. That is weird, maybe refresh the page?


#5

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