vendredi 6 mars 2015

If/else statement with no curly brackets javascript?

I've searched and I can't find a question already like this. However, why does this code work?



this.askTeller = function(pass) {
if (pass == 1234) return bankBalance;
else return "Wrong password.";
};


Shouldn't it be like



this.askTeller = function(pass) {
if (pass == 1234) {
return bankBalance;
}
else {
return "Wrong password.";
};

Aucun commentaire:

Enregistrer un commentaire