Why code is not succsefully run directly using...console.log(john.bankBalance);...............without saving it in myBalance


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();


You might need to create a variable of myBalance so that it does that then you could console.log()

var myBalance =  john.getBalance(1234);

Hope I helped! :slight_smile:


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