+ 2

Is Math.random is necessary? If yes give me some idea where ti use it mo plss.. 😊 THANKKSS

Where Math.random use for?

19th Jun 2019, 11:02 AM
Michael Gatmaitan
Michael Gatmaitan - avatar
2 Respostas
0
It is used if you want to generate a random value between 0 and 1.
19th Jun 2019, 11:11 AM
DEVANSH BANSAL
DEVANSH BANSAL - avatar
0
It can be used to generate random chances. Example: function randomChance(num) { return Math.random() > 1 / num; } It is also possible to generate other random numbers too: function random(min, max) { return Math.random() * (max - min) + min; } function randInt(min, max) { return Math.floor(Math.random() * (max - min) + min); } // Maximum is exclusive
19th Jun 2019, 12:15 PM
Airree
Airree - avatar