vendredi 9 décembre 2016

Using a variable inside the math.random function [on hold]

I am working on a piece of code which make an array full of numbers with the amount of numbers i want, but instead of this beeing static with 16 numbers i tried to change 16 to a variable but the math.floor/randome cant read it it only spits out Not a number wierdly enough.

Is There anyone who knows how to change this

while(arr.length < pictures.length) {
    var randomenumber = Math.floor((Math.random()* 16));
    if(arr.indexOf(randomenumber) > -1) {
        continue;
    }
    arr[arr.length] = randomenumber;
}

//cheat sheet
for(var i = 0; i < arr.length ; i++) {
    document.write(arr[i]);
    document.write("<br/>");
}




Aucun commentaire:

Enregistrer un commentaire