Question on printing random numbers

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

:point_up_2:this will return a random number between 0 and 50 . But i want a random number between 10 and 50 . How can i do this ? Please tell me .

Thank You
(if there is some mistake in making you understand my question then i am sorry. i am new to community , so i don’t know much about how to do stuff here.)

For this type of thing, a quick read through documentation is a great place to start. MDN is top-notch for javascript (look at the examples after scrolling down a bit):

5 Likes

In the link you gave , there is nothing which tells how to print random numbers between two specified numbers like printing a random number between 5 and 10.

Hey!

You just need to scroll down. The tab is called “Getting a random number between two values”. You can copy and paste the function directly and play around with it with 0-5, or any other number you want. You do have to change the values of min and max though for it to work. So now you have code that’ll work for any range! (don’t forget to run a rounding method like Math.floor() or Math.ceil() to get an integer value)