Hi I am really stuck with the below code. Can you please help me in fetching the expected results. I suspect the issue with the last piece of the code. Thanks in advance.
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.bankBalance
console.log(myBalance);
john.getBalance();