Hey everyone, I'm currently working on a JavaScript school project where I'm creating a dungeon. It may not be the best code out there, but hey, I'm still learning.
I'm encountering an error in the following code:
function damageFormula()
{
var damage = myDamage(myWeapon); // The error is coming from this function
var doDamage = Math.floor(0.085 * damage * myAttackLvl + (myLevelLvl/5) - (1+15*Math.random()));
return doDamage;
};
The myDamage function looks like this:
function myDamage(myWeapon)
{
switch(myWeapon)
{
case "Spike Sword":
myDamage += 10;
break;
case "Magic Long Sword":
myDamage += 20;
break;
default:
myDamage += 3;
break;
}
return myDamage;
};
The weapon variable is set as:
var myWeapon = "Spike Sword";
And the myDamage variable is set as:
var myDamage = 10;
Could someone please help me understand why I'm getting this error and possibly provide a solution?
If you require any additional information, feel free to ask me anything and I'll do my best to provide a clear answer.