I am trying to make a number simulation that functions as follows:
- Begins at baseline value
- Generates random value within given range of baseline
- Takes generated value and generate another value within same range
- All generated values remain within a larger range
I can use random() with a single defined range, but I don't know how to do two:
function generateValue(min, max) {
var max = 2,
min = 0,
value = (Math.random() * (max - min) + min).toFixed(6);
return value;
}
Aucun commentaire:
Enregistrer un commentaire