mercredi 22 février 2017

Why is my random number generator from a new array not working? Javascript

I am making a card game but right now I am having a problem with the random number generator. I am creating new array with 100 choices and then randomly selecting a number from that array. However, when I document.write correctNum, I am getting undefined. I bet the answer is simple but I can't seem to get it.

var numList = new Array(100);

var correctNum = numList[Math.floor(Math.random()*numList.length)];

document.write(correctNum);




Aucun commentaire:

Enregistrer un commentaire