Function returns undefined with ternary operator

Viewed 2084

I am trying to wrap my head around the isBreadwinner function. Why does not true pass into the (**) function. Why is Earning member:undefined

<script>
    "use strict"

    //creating a user object 
    let user = {
        name : "Stackoverflow Developer",
        age : 23
    };

    // appending properties to the user object
    user.location = "NYC";
    user["occupation"] = "JavaScript Developer";
    user["salary"] = 10;

    //(**)
    let isBreadwinner = () => {
        (user.salary) ? true : false;
    };

    console.log("asd" + isBreadwinner());
    user["Earning member"] = isBreadwinner();

    // printing the object
    console.dir("User dir object" + JSON.stringify(user));
    console.dir(user); //Earning member:undefined
</script>
2 Answers
Related