Here is the code which does not work (Nothing is added). The first line will work if I remove the comment. I suppose the variable result is not taking a number or something else. I don't really understand why.
$(document).ready(function ()
//document.getElementById(1).style.display = "inline-block";
// https://www.youtube.com/watch?v=pqLS4oyJ8cA
array.prototype.randsplice = function(){
var rndNumber = Math.floor(Math.random()*this.length);
var lstSplice = this.splice(rndNumber,1);
return lstSplice;
}
var lstNumber = new Array(0,1,2,3,4,5,6,7,8,9);
var result = lstNumber.randsplice();
document.getElementById(result).style.display = "inline-block";
var result = lstNumber.randsplice();
document.getElementById(result).style.display = "inline-block";
var result = lstNumber.randsplice();
document.getElementById(result).style.display = "inline-block";
});
I tried to followed this interesting link: Randomly Empty a Javascript Array but without success. (obviously the style display is originally set to none for all div.)
Any help will be appreciated. Thanks