What you are seeing here is the difference of how functions and how ternaries are working. A traditional if else statement is a function and needs a return statement, or it won’t do anything.
In a ternary the JavaScript engine automatically returns the result under the hood on runtime. A ternary can only be a boolean that is either truthy or falsy. The engine has a library of falsy values like ‘null’, NaN, aso… Everything that isn’t in the false library can be returned as true by the engine, without you needing to instruct it to do so.