EN · USD

Language

Prices in

USDUSD · your currency EuroEUR · what you pay

You always pay in euros. Other currencies are a guide at today's rate.

Become a tutor Sign up

Article English 1 min read

Random numbers

JS allows a developer to generate a random number by using two methods

Download PDF

JS allows a developer to generate a random number by using two methods:

Math.random() generates a random 16 decimal place number that is greater or equal to 0 and less than 1. We can multiply the return to get a range: Math.random() * 10 // between 0 and 9.9999etc Math.floor() rounds a number DOWN to the nearest whole number. Therefore… Math.floor(Math.random( ) * 10) = a random number

between 0 and

More from Maximilian Bahrami