Accessing Private Variables


i need some help here.

Oops, try again. Your getBalance function should return bankBalance;

Replace this line with your code.


i get a very different error message:

Oops, try again. Make sure you properly defined the askTeller method!

You didn't create a askTeller method, are you sure you posted the right code and exercise url?


I posted by mistake wrong link. sorry. check it now


is it the parenthesis() in return?


i see, here;

var bankBalance = john.bankBalance;

could you explain this line? Nowhere in the instructions its says you should add this

the only thing getBalance should do is to return bankBalance, this will give undefined (bankBalance is private), but then that is the point :slight_smile: We want to show you how variable scopes works within objects


ok i get it. It's been almost a month in javascript and is a little bit dificult to get it through.


This part of the JS course is certainly not easy, objects 2 and building a cash register are the two most difficult tracks. Good luck! :slight_smile: Maybe revisit some exercises?

You can always check MDN for external documentation


This is what i'll do. Thanks a lot!


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