mardi 27 septembre 2016

else return statement is shadowing else if return statement

my first statement is working correctly but it shadows the else if statement below and just duplicates, maybe because the arguments are the same? i cant seem to figure out why since i am using semicolon and properly bracketing the conditions. i would love an explanation to the solution anyone comes up with!

 function sayHiToGrandma(string) {
      if (string.toLowerCase() === 'hello') {
        return "I can't hear you!";
    }
    else if (string.toUpperCase() === 'HELLO') {
        return "YES INDEED!";
    }

    }

Aucun commentaire:

Enregistrer un commentaire