dimanche 5 juin 2016

How to generate a random number between two specific values if I dont know the min and max between the two values

I have seen many answers..

Like -Generating random whole numbers in JavaScript in a specific range?..

The solutions in Generating random whole numbers in JavaScript in a specific range? will apply to me only if i know which is greater..In this case i dont know that

But (the above link) You need to which is the min and max between Your two numbers ...Suppose i dont know the min and max...

How do i randomly generate a number if I dont which is greater amongst the two??

var num1= $("#num1").val();
var num2 = $("#num2").val();

I dont know which is greater..

So how to randomly generate a number between num1 and num2




Aucun commentaire:

Enregistrer un commentaire