I'm new to coding, and this is my first post. Any help you can offer is greatly appreciated. I'm trying to create a level calculation system that you might see in an RPG for a character with different stats. When I run the program at different values, I get the following message:
Unexpected token 'this'
I have put the section of code where the error message occurs in stars.
const Sean = {
fullName: `Sean`,
attack: 1,
strength: 1,
defense: 38,
hitpoints: 40,
prayer: 15,
range: 98,
magic: 99,
calcCombatLevel: function () {
this.Meleelvl = .25 * (this.defense + this.hitpoints + Math.floor((this.prayer / 2))) + ((13 / 40) * (this.attack + this.strength));
this.magiclvl = .25 * (this.defense + this.hitpoints + Math.floor((this.prayer / 2))) + ((13 / 40) * (this.magic * (3 / 2)));
this.rangelvl = 0.25 * (this.defense + this.hitpoints + Math.floor((this.prayer / 2))) + ((13 / 40) * (this.range * (3 / 2)));
if ((this.attack + this.strength) > ((2 / 3) * this.magic) && (this.attack + this.strength) > ((2 / 3) * this.range)) {
return this.meleelvl;
}
// **********************************
else if ((2 / 3) this.magic > (this.attack + this.strength) && (this.magic >** this.range)) {
return this.magiclvl;
}
else if((2 / 3) * this.range > (this.attack + this.strength) && (this.range > this.magic)) {
return this.rangelvl;
}
}
}
Sean.calcCombatLevel();
console.log(Math.floor(Sean.lvl));