When I try to run a method from this object it says that the object is not defined. I'm sorry if it's a stupid question I checked many times and cant seem to find an error so I appreciate your help and patience.
let Sunce= {
dvaujedan: function (name){
this.prva(name);
this.druga();
},
prva: (name){
switch(name){
case "Elena":
player = new Player ("Elena" , 100, 200, 50, 100, 400);
break;
case "Anabel":
player = new Player ("Anabel" , 200, 300, 150, 200, 100);
break;
case "Silvia":
player = new Player ("Silvia" , 100, 200, 50, 200, 300);
break;
}
let getinterface =document.querySelector(".interface");
getinterface.innerHTML= '<img src="img/player/' +
player.name.toLowerCase() + '.jpg"> <h3>' +
player.name + '</h3><p>Speed:' + player.speed + '</p><p>Health:' +
player.health + '</p><p>Damage:' + player.damage +
'</p><p>Agility:' + player.agility +
'</p><p>Mana:' + player.mana + '</p>';
},
druga: (){}
}
It seems like the object will cause SyntaxError
because of prva
and druga
. You should add function
for those 2 functions.
dvaujedan: function (name){
...
},
prva: function (name){
...
},
druga: function (){}