25. Private methods


#1

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(){

}}

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

It constanly returns with the title, my balance is not a funciton and undefined.


#2

var myBalanceMethod = 
var myBalance = myBalanceMethod();
console.log(myBalance);

I don't understand the purpose of all of this, I believe you're simply overthinking it.

console.log(john.returnBalance);
console.log(john.askTeller());

I'm not sure what myBalanceMethod is either, that doesn't make much sense to me because myBalanceMethod() was never defined.

LASTLY!

this.askTeller = function() {
 //INSERT CODE!
}

I hope this answers your questions but if you have any more let me know and I'll explain it further! :+1:


#3

Thank you that worked, No those were originally left there in the skeletal code. And it confused me

From what i understand what i was doing wrong was not declaring where askTeller was from


#4

Alright, I do apologize as I didn't reference the lesson, I went solely off what I saw. My mistake!


#5

Haha no, Its fine You helped me either way.