24, cant understand the error


#1



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

Oops, try again. You should print myBalance after setting myBalance to john.getBalance()!


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);
console.log(john.bankBalance);

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


#2

Delete john. from the last line:


#3

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