If/else short Statement


Hi everyone;

I am starting with javascript in the course Java Script Introduction and in the point 7… Function Declarations of Section 3 - Functions, the program does not accept the short condition within a function:
“numberOne > numberTwo ? return true : return false;”

that pretends to verify if #1 is grater then #2… If I use the “usual” if/else statement it works.

Someone could explain me why that bug occurs?
Thank u in advance.


You didn’t use the ternary operator correctly:


but even if you did, the exercise would never approve it given the exercise validation isn’t designed to handle it.


Thank u!

So, basically it is missing return(…); Right?



you have return:

return true : return false

but at the wrong place, here you should only determine the value (true : false) and then what you want to do with this value (return, assign it to variable) should happen at the beginning of that line


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.