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 (isMonsterH&& inventory.length !== 1)() {
monsterHealth -= weapons[currentWeapon].power + Math.floor(Math.random() * xp) + 1;
} else {
text.innerText += " You miss.";
}
healthText.innerText = health;
monsterHealthText.innerText = monsterHealth;
if (health <= 0) {
lose();
} else if (monsterHealth <= 0) {
fighting === 2 ? winGame() : defeatMonster();
}
if (Math.random() <= .1) {
text.innerText += " Your " + inventory.pop() + " breaks.";
currentWeapon--;
}
}
Use the logical AND operator &&
to add a second condition to your if
statement. The player’s weapon should only break if inventory.length
does not equal (!==
) one.
Hi I am just wondering what I am doing wrong. The console is telling me that I need to use && operator for the adding a condition. I did that if (isMonsterHit() && inventory.length !== 1) . curious what I am doing wrong?