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

Tell us what’s happening:

I don’t understand how i have a syntax error when in order to get to this step I’ve had to enter everything correctly. I’m not understanding the syntax error.

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();
}

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 (Windows NT 10.0; Win64; x64) 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 149

Hello @staysavy32 !
While calling the isMonsterHit function, use it as a condition in the if statement.

if (condition) {
}
1 Like

that still doesn’t help. what did you add that i don’t have?

Can I see what you have?

1 Like

It’s just the earlier code that I am seeing. I’m asking for the code you’ve made the changes I suggested.

1 Like

What I suggested is what the lesson requires, if it was declined, then the problem must be in other sections of your code. That is why I asked for the updated code.

1 Like

that doesn’t make sense, in order to get to this step my code has to be correct. Thanks for nothing have a nice night.

Did you figure it out?
Remember how you have to write a function.
This is a function:
function example()

So when you call a function you have to write what staysavy32 said.

if (example()) {
}

Hope this helps…

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.