In the "Basic JavaScript: Use Multiple Conditional (Ternary) Operators" challenge, the JS parser does not seem to consider the following valid:
function checkSign(num) {
return
num > 0 ? "positive" :
num < 0 ? "negative" :
"zero";
}
checkSign(10);
If you change it to this, however, it passes:
function checkSign(num) {
return num > 0 ? "positive" :
num < 0 ? "negative" :
"zero";
}
checkSign(10);
It is not valid. When you put a return on single line by itself, the function will return undefined. Please close this, because it is not a bug. but instead a JavaScript feature. The following would be valid (wrapping with parentheses).
function checkSign(num) {
return (
num > 0 ? "positive" :
num < 0 ? "negative" :
"zero"
);
}
Ah, you're right. Thanks. :smile: Closing this issue.
THIS GUY DESERVES A ROUND OF APPLAUSE
Most helpful comment
It is not valid. When you put a return on single line by itself, the function will return undefined. Please close this, because it is not a bug. but instead a JavaScript feature. The following would be valid (wrapping with parentheses).