So guys I am trying to make a function that returns a random number (which I need that code to be executed excluesively) generate the same number for different two functions. Basically I am going to call a function that returns a random number but when I call that function again, I need it to be the same number as in the previous function (I am not very good at javascript.). I have these codes, but of course it generates some another number in each function:
function gen() {
return Math.floor(Math.random() * 21) + 40;
}
function chan() {
var rand = gen();
}
function sell() {
var rand = gen();
}
Aucun commentaire:
Enregistrer un commentaire