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

We don’t want a player’s only weapon to break. The logical AND operator checks if two statements are true.

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.

Please I’m stuck here:
if (isMonsterHit() && inventory.length !== 1) {}
This is what i did and it didnt pass

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

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

I don’t think the first condition in your if statement is complete. The second condition is okay though. send your complete code

Hello!

Correct syntax, wrong if condition. Look for the one that describes the player’s weapon breaking and modify the condition there.

Here is the complete code. I updated the logical and operator in the if condition. i cant seem to find the first condition.

health -= getMonsterAttackValue(monsters[fighting].level);
if (isMonsterHit() && inventory.length !== one) {
monsterHealth -= weapons[currentWeapon].power + Math.floor(Math.random() * xp) + 1 ;

one is no data type, you will get an undefined when you try this. You are comparing to data type number. You also are still in the wrong if statement there is one down below describing the weapon breaking…

This time I am really stuck. Please help!

Step 157

We don’t want a player’s only weapon to break. The logical AND operator checks if two statements are true.

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.

Here’s my code:

if (Math.random() <= .1 && inventory.length != 1) {
text.innerText += " Your " + inventory.pop() + " breaks.";
currentWeapon–;

}