Learn-basic-javascript-by-building-a-role-playing-game - Step 157

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?

It looks like you edited the wrong if statement.

i would suggest resetting the lesson.

The if statement, you want to update is this one here

if (Math.random() <= .1) {
    text.innerText += " Your " + inventory.pop() + " breaks.";
    currentWeapon--;
  }

Yeah I figured it out. How the instruction is worded is funky. It wanted you to figure out the answer through implication. I.e. weapon breaking is the key to where the code needs to be applied. Thank you Miss oboe. sounds nigerian