3/7 Short-term memory


#1

I've tried changing several things, and keep getting multiple errors. Right now, it says that scan is not defined, and I get a pop up asking if I've scanned eggs twice and magazine three times. Help me out. Here's my code:

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

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

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

    //Add other 2 items here
    case "magazine":
        this.add(4.99);
        break;

    case "chocolate":
        this.add(0.45)
        break;
    };
    return true;
},

};

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


#2

Hi try to call all your scan like that

cashRegister.scan('eggs');