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

Tell us what’s happening:

Is the ternary syntax is wrong
I suppose to return hit if it’s greater than 0
any help!?

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

function getMonsterAttackValue(level) {
  const hit = (level * 5) - (Math.floor(Math.random() * xp));
  console.log(hit);
  return  hit > 0 ? hit : default_hit;
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 15_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/119.0.6045.169 Mobile/15E148 Safari/604.1

Challenge Information:

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

Hey there!
In getMonsterAttackValue, change return hit to a ternary operator that returns hit if hit is greater than 0, or returns 0 if it is not.

Correct that last value, according to instructions. Remember you didn’t need default word and _
@mohmedyahya833

1 Like

Thanks much for your help
The test passed

Your welcome. Happy Coding.

1 Like