I’m trying to generate a random number between 10 and 50 inclusive (the interval [10,50]) in JavaScript. I don’t need it to be an integer only, it can be any value in that interval. I know I need to use Math.random()
, I’m just stuck on what the code would be to get that particular interval.
I’ve tried Math.random() * 50 + 10
, but this doesn’t seem to give me values in the right interval I am looking for.
Aucun commentaire:
Enregistrer un commentaire