Private methods 25/30


#1

The exercise with this error , I need help because I can not make it work .

undefined
TypeError: myBalanceMethod is not a function


function Person(first,last,age) {
this.firstname = first;
this.lastname = last;
this.age = age;
var bankBalance = 7500;

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

// crie a nova função aqui
this.askTeller = function() {
var myBalance = myBalanceMethod();
}
}

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


#2

@designplayer26623,

function Person(first,last,age) {
   this.firstname = first;
   this.lastname = last;
   this.age = age;

   var bankBalance = 7500;

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

// crie a nova função aqui
   this.askTeller = function() {
      return returnBalance;
   };
}

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

#3

Thank you very much , helped me a lot .