+ 5
[DUPLICATE] How to get random results in js?
please post an example for that.
6 Answers
+ 5
Use Math.random() to produce random numbers between 0 and 1 that can be used as values to your program to achieve random results.
Here's a sample code.
Edit: the code now shows random values of an array.
https://code.sololearn.com/WGzpyAXmUxo3/?ref=app
+ 8
Just referring this thread.
https://www.sololearn.com/discuss/1301613/?ref=app
+ 7
You can generate a random number by Math.random function in js.
For getting a whole number between two number without decimal places is to Math.floor(Math.random()*10)+1. This generates a random number between 1 to 10. See my code.
https://code.sololearn.com/WtdDN6s147SU/#html
+ 6
Jonathan Pizarra
Akash Pal
not that . how to get random text from an array?
for example, if we had two words such as HTML and js .it must display a random one.
+ 5
ok...Jonathan Pizarra
+ 3
Gangineni Goutham Choudary check my code again. I have edited it.



