Problems with an unexpected token, not sure what to use in its place

Tell us what’s happening:

the semi colon at the end of the code is an unexpected token?

Your code so far


function checkSign(num) {
    return (num > 0) ? "positive" : (num = 0) ? "zero" : (num < 0) ? "negative" ; 
}

checkSign(10);

Your browser information:

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

I dislike chaining these types of commands,… but if you must,

each “?” requires a IF_TRUE and IF_FALSE

(condition) ? IF_TRUE : IF_FALSE

At the end of your statement you have:

(num < 0) ? “negative”;
(condition) ? IF_TRUE;

The ; is an unexpected token because it expects to find ‘:’ and IF_FALSE instead.

1 Like