Cash Register 3/7 Scan is not defined error


#1

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

scan: function (item) {
    switch (item) { 
    case "eggs": 
        this.add(0.98); 
        break;
    case "milk": 
        this.add(1.23); 
        break;
    case "magazine":
        this.add(4.99);
        break;
    case "chocolate":
        this.add(0.45);
        break;
    //Add other 2 items here


    }
    return true;
}

};

//Scan 2 eggs and 3 magazines
scan('eggs');
scan('eggs');
scan('magazines');
scan('magazines');
scan('magazines');

//Show the total bill
console.log('Your bill is '+ cashRegister.total);


#2

Hi first you called magazine with "s" and you should call it like that cashRegistrer.scan('magazine'); ....your add function should be like that

add: function(itemCost) {
    this.total += itemCost;