Accessing Private Variables


#1


Hello,
i need some help here.


https://www.codecademy.com/courses/objects-ii/4/3?curriculum_id=506324b3a7dffd00020bf661#


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


Replace this line with your code. 
https://gist.github.com/53b441818c6cea82d371a8746944ab1f


#2

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?


#3

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


#4

is it the parenthesis() in return?


#5

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


#6

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


#7

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


#8

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


#9

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