Learn Basic JavaScript by Building a Role Playing Game - Step 147

Tell us what’s happening:

Según yo esta bien hecho el código que es lo que esta fallando?

Instruuccion:
In your attack function, below the health variable, create an if statement. Set the condition to call the isMonsterHit function.

Código
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 (health > 0) {
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) {
if (fighting === 2) {
winGame();
} else {
defeatMonster();
}
}

}

Your browser information:

El agente de usuario es: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

Challenge Information:

Learn Basic JavaScript by Building a Role Playing Game - Step 147

Este es tu código:

if (health > 0) {
    isMonsterHit();
}

instrucciones:

Crea una declaracion if. haz que en la condicion se llame a la funcion isMonsterHit.

en tu caso tu condición es health > 0, pero deberías llamar a la función isMonsterHit en la condicion.

Para agregar tu codigo usa el boton </>
image
y pega tu código entre las comillas triples
image