23. Private Variables


#1


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


I don't know why is says ReferenceError: John is not defined. I do understand that I'm not supposed to be able to print John's bankBalance and I did try so this is confusing. Can someone please help me? I don't know if I need to add something or take something out.


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','Ross',61);
var myFirst = john.firstName;
var myLast = john.lastName;


// try to print his bankBalance
console.log(John);


#2

The above lines are not asked for, so don't create them. Only give what is asked for and these lessons will be easier to pass.

console.log(John);

As the error reads, John is not defined. john is, but this still does not match the instructions.

console.log(john.bankBalance);

This is deliberate, on the part of the author. It is supposed to raise an error, so expect it.


#3

Thank you so much. Sometimes a second set of eyes is all it takes.


#4

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