23. Private Variables



So, i passed this exercise, but the result is 'undefined'. Am i missing something or what? Any help would be useful. :smiley:

function Person(first,last,age) {
   this.firstname = first;
   this.lastname = last;
   this.age = age;
   var bankBalance = 7500;

// create your Person 
var john = new Person('John','Smith',30);
var bankBalance = john.bankBalance;
// try to print his bankBalance


Yea, you are suppose to get undefined since bankBalance is private. You could have either reached this conclusion by reading the information of the exercise, or move on to the next exercise where this is explained in even more detail


Stupid me, thanks for such a fast response. :slight_smile: