Skip to main content

Ivan Teoh

Something personal yet public

165-exercise.js

(Source)

function stringGuess(aString) {
    // 'default' operator
    var checkString = aString || "aString is falsy value.";
    // 'guard' operator
    if (checkString && checkString.length)
        return checkString;
    return "aString is not a string";
}

var man = 0;
alert(stringGuess(man));
alert(stringGuess(52));
alert(stringGuess("10"));