Did you remember to add cases for magazine and chocolate? Are all your prices accurate?


#1

var cashRegister = {
total: 0,
//insert the add method here
add : function(itemCost) {
this.total+= itemCost;
},

scan: function (item,quantity) {
    switch (item) { 
    case "eggs": 
        this.add(0.98 * quantity); 
        break;

    case "milk": 
        this.add(1.23 * quantity); 
        break;

    //Add other 2 items here
    case "magazine" :
        this.add(4.99 * quantity);
        break;
    case "chocolate" :
        this.add(0.45 * quantity);
        break;
    }
    }};

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

output: Your bill is 16.93


#2

i got it
it was just simple as calling the scan function twice with egg and thrice with magazine.
no multiplication or loop needed
i think codecademy wants the same thing,
just the next exercise is about following the DRY rule.