lundi 19 juillet 2021

Random number generator every time the program runs (javascript)

I am trying to write a code that makes a new random number every time it runs. I have a function here, there is no syntax errors but why does my code not run? And when it does all it does is spit out undefined?

function GetRandomInteger(a, b){

    if (a > b){
        small = b;
        large = a;
    }
    else{
        small = a;
        large = b;
    }

}

var randomInt = GetRandomInteger(1,5);

console.log(randomInt);



Aucun commentaire:

Enregistrer un commentaire