If/else IN METHODS


#1

Take a look at the if/else statements in the this.askteller method:

function Person(first,last,age) {
   this.firstname = first;
   this.lastname = last;
   this.age = age;
   var bankBalance = 7500;
  
    this.askTeller = function(pass) {
      if (pass == 1234) return bankBalance; //This is suprising no f***ing curly braces
      else return "Wrong password.";          //o_o
    };
}

Is this form of if/else only possible in methods? i.e., without the curly braces?

`


#2

HI yes you can Omit the curly brackets you can read more about it here


#3

Thanks for clarifying. ^^


#4

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