|
|
|||||
|
Ready to Use Script Archive | | | Over 5000 Free Fonts | | | Tutorials | | | Javascript Forum | | | Other Javascript Resources | | | Cheat Sheet |
Random NumbersQuestion: How do I generate random numbers in JavaScript?
Answer: To generate random floating-point numbers in the range from 0 to 1,
use the num = Math.random() // num is random, from 0 to 1If you need random floating-point numbers in the range from A to B ,
use this code:
num = A + (B-A)*Math.random() // num is random, from A to B |
|