Private Methods - Whats wrong!


#1

Don't Worry I have found a solution


#2

I don't think so

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


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.