24 / problem?


Bonjour, j'ai un petit soucis avec cet exercice, quelqu'un voit ou j'ai pu me tromper ?

function Personne(prenom,nom,age) {
this.prenom = prenom;
this.nom = nom;
this.age = age;
var compteEnBanque = 7500;

this.getCompte = function() {
// votre code doit retourner le compteEnBanque
return compteEnBanque

var john = new Personne('John','Smith',30);

// Créez une nouvelle variable monCompte qui appelle getCompte()
var monCompte = john.getCompte


Merci de votre coup de mains !!


Perhaps you could describe the problem?

What's happening and what should happen instead?


i just find the solution, i missed a () after :
var monCompte = john.getCompte
Now it's working !


I had the same probalme, I dont understand though, why i had to add the () to the john.getBalance like this:
var myBalance = john.getBalance();

why it is not enough to write:
var myBalance = john.getBalance;


You must write the line:

var myBalance = john.getBalance();

because "get.Balance()" is a method.

If you only wrote:

var myBalance = john.getBalance;

Those parentheses on the end indicate a function or method. Javascript would think "getBalance" is a variable that perhaps has not yet been created.