mardi 1 mai 2018

Can someone please explain what this bit of javascript code is doing?

So I'm completely new to programming and trying to understand what this piece of javascript code is doing specifically lines 3 and 4 am I right in assuming it's checking the array for the randomly generated number and if it's not present in the array it adds it and then if it's true it will place that number in the document ID?

var numarray = new Array(76);
do {
  var rannum = Math.floor(Math.random() * 76) + 1;
} while (numarray[rannum]);
numarray[gNumber] = true;
document.getElementById(cellID).innerHTML = rannum;



Aucun commentaire:

Enregistrer un commentaire