I am going through the JavaScript curriculum of FreeCodeCamp and I am stuck trying to get a return value for the 'hit' variable by using a ternary operator.
What FCC wants me to do to pass the challenge:
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.
function getMonsterAttackValue(level) {
const hit = (level * 5) - (Math.floor(Math.random() * xp));
console.log(hit);
return hit > 0 ? 'hit' : '0'
}
You could simply take the larger value with
Math.max.