Private Methods


#1

I get this code and it doesnt work. Why? Thank you.

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();
};

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


#2

function Person(first,last,age) {

where is the } to mark the end of your Person function?


#3

I have just found that syntax error. But thank you a lot.


#4