Tell us what’s happening: The question asks to just make an if statement with the given condition ‘isMonsterHit’. I really don’t know what the condition for the function that is called is supposed to be and the tip is not really giving me anything to go with.
The tip given is: “You should add an if
statement which calls isMonsterHit
in the condition.” Which I feel I have done.
### Your code so far
function attack() {
text.innerText = "The " + monsters[fighting].name + " attacks.";
text.innerText += " You attack it with your " + weapons[currentWeapon].name + ".";
health -= getMonsterAttackValue(monsters[fighting].level);
if (isMonsterHit){
}
monsterHealth -= weapons[currentWeapon].power + Math.floor(Math.random() * xp) + 1;
healthText.innerText = health;
monsterHealthText.innerText = monsterHealth;
if (health <= 0) {
lose();
} else if (monsterHealth <= 0) {
fighting === 2 ? winGame() : defeatMonster();
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 149