24. Accessing Private Variables



TypeError: bankBalance is not a function

I can still get throught to the next lesson. But i don't understand why it's not showwing any balance!

function Person(first,last,age) {
   this.firstname = first;
   this.lastname = last;
   this.age = age;
   var bankBalance = 7500;
   this.getBalance = function() {
      // your code should return the bankBalance
      return bankBalance();

var john = new Person('John','Smith',30);

// create a new variable myBalance that calls getBalance()
var myBalance = john.getBalance();


Hi this line

return bankBalance();

remove the ()


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