25/30 - What am I doing wrong?


#1

here is my code :

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
var 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);

It returns 2 underfined, and Make sure you properly defined the askTeller method! message error. @rydan ?


#2

You will have to change

var myBalanceMethod = john.askTeller;
var myBalance = myBalanceMethod;

into

var myBalanceMethod = john.askTeller();
var myBalance = myBalanceMethod();

#3

I just tried. It says : TypeError: john.askTeller is not a function


#4

should be changed into

this.askTeller = function() {
   return returnBalance;
 };

#5

yes ! make sense also ^^' thank you very much leonhard :grin: