26/30 - Passing Arguments - If/Else no brackets?


#1

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;
     else return "Wrong password.";
   };
}

Why in the .askTeller function, the if/else statement has no brackets?

Thanks


#2

I mean its a thing. Normally its best practice if you do, but if you want you can get them out. Like this:

Two ways of doing it:

Bracket way

var age = 14;
if(age>14){
console.log("Big Boy")
}
else{
console.log("Maturing..")
}

And the no Bracket way

var age = 14;
if(age>14)
console.log("Big Boy")

else
console.log("Maturing..")

Reccomendation:

Again i recomend the bracket way since its best practice, i do the bracket way.