I tried following the example given in this step and I am getting an error, I would like some help
Your code so far
function getMonsterAttackValue(level) {
const hit = (level * 5) - (Math.floor(Math.random() * xp));
console.log(hit);
if (hit > 0) {
return 'hit is greater than 0';
}
else {
return 'hit is smaller than or equal to 0';
}
return hit > 5 ? 'hit is greater than 0' : 'hit is smaller than or equal to 0';
}
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/121.0.0.0 Safari/537.36
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 146
Use the ternary operator. Delete the if/else statement:
return smth > value ? if smth is greater than the value return the value : else return zero
This is guidance.
For the True part of the ternary operator you should use only the required value which is hit, and for the False part use the number 0.
Read the instructions again.
Instead of the text 'hit is greater than 0' use only hit (you want it to be returned if it is greater than 0). After the colon use only the number 0 (you don’t need any string here, in other words, don’t use quotes at all).