+ 5

Random on javascript

did anybody know how to make a random function on sololearn

24th Jan 2018, 10:21 AM
Blizz
Blizz - avatar
2 Answers
+ 10
Math.random(); use👇 var a = Math.random(); So the value of a would be anything between 0 to 1 As per your use you could perform multiply addition division etc... A random dice would be document.write(Math.round(Math.random()*5+1); this☝will result in a random dice..😊
24th Jan 2018, 10:27 AM
Jaydeep Khatri
Jaydeep Khatri - avatar
24th Jan 2018, 10:24 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar