Mémoire immédiate


#1

what's wrong i can't see my fault

var = caisse {
total: 0,
// Ecrivez la méthode ci-dessous ajouter:
ajouter: function (coutElement) {
this.total += coutElement;

};

scan: function (element) {
switch (élément) {
case "oeufs:
this.ajouter (0,98);
break;

case "lait": 
    this.ajouter (1,23); 
    break;

// Ajoutez Deux Autres éléments ci-dessous
case "magazine":
    this.ajouter (4,99);
    break;

case "chocolat":
    this.ajouter (0,45);
    break;
default:
    console.log("Wat???");
    break;
}

}
return true;

}
};

// 2 Scannez et 3 oeufs magazines
caisse.scan("oeufs");
caisse.scan("oeufs");
caisse.scan("magazine");
caisse.scan("magazine");
caisse.scan("magazine");

// Affichez le total de
console.log ( 'Votre totale is de' + caisse.total);


#2

Hi first this line

var = caisse {

should be like that

var  caisse = {

and here remove the ; at the closing } and put ,

ajouter: function (coutElement) { 
    this.total += coutElement;
}; <--- put ,

and here

switch (élément)

you should change the é with just e on this case

case "oeufs:

you didn't closed the string then this part

....
    default:
        console.log("Wat???");
    break;
    }
} <-- remove this one 
return true;
}
};

it hsould be like that

...
   scan: function(element) {
       switch (element) {
        ....
       }
       return true
   }
};

#3

i wrote this not work he send me problem with your syntax

var caisse = {
total:0,
// Ecrivez la méthode ajouter ci-dessous :
ajouter: function(coutElement) {
this.total += coutElement;
}

scan: function(element) {
    switch (element) { 
    case "oeufs": 
        this.ajouter(0.98); 
        break;

    case "lait": 
        this.ajouter(1.23); 
        break;

    // Ajoutez deux autres éléments ci-dessous
    case "magazine":
    this.ajouter(4.99);
        break;

    case "chocolat":
        this.ajouter(0.45);
        break;


    }
    return true;
}

};

// Scannez 2 oeufs et 3 magazines
caisse.scan("oeufs");
caisse.scan("oeufs");
caisse.scan("magazine");
caisse.scan("magazine");
caisse.scan("magazine");

// Affichez le total
console.log('Votre total est de '+caisse.total);


#4

it's missing the , after the closinf } here

ajouter: function(coutElement) {
   this.total += coutElement;
}, <--

,


#5

thx a lot bro :slight_smile:


#6

what's wrong

var caisse = {
total:0,
//N'oubliez pas d'ajouter votre propriété

ajouter: function(prixElement) {
    this.total += prixElement;
    this.prixDerniereTransaction -= prixElement;
    this.prixDerniereTransaction = 0;
},
scan: function(element, quantite) {
    switch (element) {
    case "oeufs": this.ajouter(0.98 * quantite); break;
    case "lait": this.ajouter(1.23 * quantite); break;
    case "magazine": this.ajouter(4.99 * quantite); break;
    case "chocolat": this.ajouter(0.45 * quantite); break;
    }
    return true;
},
//Ajoutez la méthode annuleDerniereTransaction ici 
annuelleDerniereTransaction: function() {  
this.total -= this.prixDerniereTransaction;

},

};

caisse.scan('oeufs', 3);
caisse.annuelleDernireTransaction();
caisse.annuelleDernireTransaction();
caisse.annuelleDernireTransaction();

//Annulez la dernière transaction et ajoutez 3 à la place

// Affichez le total de la note
console.log('Votre total est de '+ caisse.total);