Don't know where I get wrong with my register


#1


https://www.codecademy.com/en/courses/close-the-super-makert/0/3?curriculum_id=506324b3a7dffd00020bf661#


Can someone help me to take a look for me?
I got the error message"Oops, try again. Did you remember to add cases for magazine and chocolate? Are all your prices accurate?"

My total came out right. I can't figure it out where I got wrong...........


var cashRegister = {
    total: 0,
//insert the add method here    
    add : function(itemCost){
    this.total += itemCost; 
    },
    
    scan: function (item,quan) {
        switch (item) { 
        case "eggs": 
            this.add(0.98 * quan); 
            break;
        
        case "milk": 
            this.add(1.23 * quan); 
            break;
        
        //Add other 2 items here
        case "magazine":
            this.add(4.99 * quan);
            break;
        case "chocolate":
            this.add(0.45 * quan);
            break;
        
        }
        return true;
    }
};

//Scan 2 eggs and 3 magazines
cashRegister.scan("eggs", 2);
cashRegister.scan("magazine", 3);
//Show the total bill
console.log('Your bill is '+cashRegister.total);


#2

adding too much code (quan) will trigger error. Remove quan and simply call the scan method multiply times.

You will work on a good way to work with quantities later.


#3

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