Private methods.. really stuck with this one


#1

function Person(first,last,age) {
   this.firstname = first;
   this.lastname = last;
   this.age = age;
   var bankBalance = 7500;
   var returnBalance = function() {
      return bankBalance;
   };
this.askTeller=function(){
    returnBalance();
}
}
var john = new Person('John','Smith',30);
console.log(john.returnBalance);
var myBalanceMethod = john.askTeller();
//var myBalance = myBalanceMethod();
console.log(myBalance);

#2

Hi try to do that here

//var myBalance = myBalanceMethod();

Remove the // before it because it put It as comment .


#3

You also need to return returnBalance
function Person(first,last,age) {
this.firstname = first;
this.lastname = last;
this.age = age;
var bankBalance = 7500;

var returnBalance = function() {
return bankBalance;
};

// create the new function here
this.askTeller = function() {
return returnBalance; :sunglasses:
}
}

var john = new Person('John','Smith',30);
console.log(john.returnBalance);
var myBalanceMethod = john.askTeller();
var myBalance = myBalanceMethod();
console.log(myBalance);