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

In this challenge i was asked to change return hit to a ternary operation
please i need to point out what’s wrong in my code

### Your code so far

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

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 148

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

Are you returning what is being requested? I don’t see true or false listed as what you are supposed to return.

1 Like

I did or is this not how it’s meant to look?

You are returning true and false. That’s not what the instructions are asking you to return. The function is called getMonsterAttackValue - true and false aren’t values indicating how hard the monster hit.

2 Likes