javascript - Re-filling an array when it is null -
hi there wonder if help.
i have random number generator when press button reduces amount of numbers in array ie. 1 got randomised has been used , removed.
var crds = math.floor((math.random()*myarray.length)); myarray = ["2","4","6","8","10","100","20","bingo!"]; array.prototype.removebyindex = function(index){ this.splice(index,1) }
i have not included attachements button presses code tells story - when button pressed splices array via index of number randomised. not know how re-initialise array when numbers have been removed.
if(myarray[crds]==null){ myarray = ["2","4","6","8","10","100","20","bingo!"]; }
any appreicated
try this
if (myarray.length == 0) { myarray = ["2", "4", "6", "8", "10", "100", "20", "bingo!"]; }
Comments
Post a Comment