mardi 2 juin 2015

Math.Random on javascript get random between two values [duplicate]

This question already has an answer here:

I am new to javascript and trying to understand Math.Random(). I have quite some experience with c# and I know that you can use random.next(1,10) to get numbers between 1 and 10. How is this with javascript. I tried serveral things like: math.Random(1,10) but this won't return the right value for me (between 1 and 10). I also informed alot of site's claiming this is the way to go. Like this one. However when I try this in w3schools I get not the suspected values. So please an explaination for this . Thank you in advance. Also I'm aware of this question but this do's not provide me the answer since there is no answer that answers the question: how to get a random number between two values. EDIT Okay so my question now is. Could someone please give me a brief explaination WHY I can't simply put two values and get a random value between them?




Aucun commentaire:

Enregistrer un commentaire