console.log value from random array give me variable is not defined . JavaScript -
im trying value of array, gives me error rand ( variable) not define. array working fine , adding values class.. cant understand why not working.
this function.
function addevent(){ var addevent = "add"; var addclass= document.getelementsbyclassname(addevent); addclass=addclass[addclass.length-1]; addclass.addeventlistener("click", adddiceevent, true); var dicearray = array=[ "one", "two", "three", "four", "five", "six"]; console.log("when set",addclass); function adddiceevent() { var rand = dicearray[math.floor(math.random() * dicearray.length)]; dicesides_func.call(addclass,rand); } } // console.log(rand) gives error # uncaught referenceerror: rand not defined # addevent();
javascript
No comments:
Post a Comment