I want to get a random number from an array but I am getting the error: Cannot read property 'length'.
//Attack arr
var attackID = [0,1];
//Start game
function start(){
console.log("Your new username is "+localuser.username+"!");
var r_atk = Math.round(Math.random()*(attackID.length-1));
if(attacks[r_atk] == 0){
punch(enemy.name);
}
else if(attacks[r_atk] == 1){
kick(enemy.name);
}
}
To look at the full code click Here and press ctrl + u
Aucun commentaire:
Enregistrer un commentaire