26. Pasing arguments if statement without curly brackets


#1


Objects II 26. Pasing arguments


In this course we learned to use if else statement as follows:
if (some condition) {
result
}

however in this exercise the syntax is completely new to me. Can you explain why the if statement uses the return without the curly brackets?

Replace this line with your code. 
 this.askTeller = function(pasw) {
     if (pasw == 1234) return bankBalance;
     else return "Wrong pasword.";
   };


#2

this stackoverflow question, explains a nicely. When the if/else contains one line, you can leave the curly brackets out (its not recommended, but its valid)


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.