24. accesing private variables, one question


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

Hello, i had no problems to finish the exercise but i have a few questions about, this is my code, working ok:
<Below this line, add a link to the EXACT exercise that you are stuck at.>
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);

var myBalance = john.getBalance();
console.log(myBalance);

And this is my question, instead of writing a new variable that hold the balance ( var myBalance = john.getBalance() ), why dont print the balance directly with john.getBalance() ? .
Is this another correct form to reveal the balance but the exercise is programmed to work only between his parameters or am i wrong?

<In what way does your code behave incorrectly? Include ALL error messages.>

```

Replace this line with your code.

<do not remove the three backticks above>

#2

@jamona,
The getBalance() Method will return a Value with NoDisplay.

So either you use
console.log( john.getBalance() );
or via two-steps
var myBalance = john.getBalance();
console.log(myBalance);