Help me understand this

Why is the code not working if the return and the ternary operator are not on the same line?

Your code so far


function checkSign(num) {

return 
num > 0 ? 'positive' : num < 0 ? 'negative' : 'zero';
}

checkSign(10);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36.

Challenge: Use Multiple Conditional (Ternary) Operators

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/use-multiple-conditional-ternary-operators

The return keyword on a line by itself will simply return undefined. You must either the value/expression you want returned on the same line or wrap it with ( and ). JavaScript interprets end of lines as end of statements (in most cases). We typically use semi-colons as a best practice to explicitly define the end of statement. Putting the return on a separate line tells JavaScript to just exit the function and return a value of undefined.

Here is an example:

function whatSize(arg) {
  return (
    arg < 10 ? 'small' : 'large'
  );
}

whatSize(5); // small

Thank you! Its clear now .