26. Pasing arguments if statement without curly brackets


Objects II 26. Pasing arguments

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

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.";


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)


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