Tell us what’s happening:
I’m being asked to update the following:
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.
Here is an example of returning a value based on condition
with a ternary:
return condition ? true : false;
I updated per my code below, and get the message " You should use a ternary to return 0
if hit
is not greater than 0
." I’ve tried other variations such as “0”, zero, and leaving the false space blank, and am wondering if I need to keep it at 0 and rephrase the condition.
### Your code so far
function getMonsterAttackValue(level) {
const hit = (level * 5) - (Math.floor(Math.random() * xp));
console.log(hit);
//editable area
return hit > 0 ? hit() : 0;
//editable area
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 148