How to use Math.random() to get a floating-point number between 0 (inclusive) and 1 (exclusive) in JavaScript

1 Answer

0 votes
document.write("Math.random() = " + Math.random() + "<br />");
document.write("Math.random() = " + Math.random() + "<br />");
document.write("Math.random() = " + Math.random() + "<br />");

 
/*
run

Math.random() = 0.42492680378474395
Math.random() = 0.181915782729497
Math.random() = 0.7049356370627149
 
*/

 



answered Aug 5, 2016 by avibootz
...