3/7. I don't see the problem in the french version!


#1


https://www.codecademy.com/fr/courses/javascript-beginner-fr-FR-4ttc1/0/3?curriculum_id=5355c2b7516bcbd912000008#


This is my code :


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

**Oups, merci de réessayer. There was a problem with your syntax.**

**SyntaxError: function statement requires a name**


#2

I have resolved the 3/7.


#3

The above is closing the object literal before the scan method. Remove the last curly brace, };.


#4

Thank you.
I have done it.


#5

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