Cash register


#1

Please tell me why this isn't working! Thanks

var cashRegister = {
total: 0,
add: function (itemCost){
this.total + itemCost = this.total; },

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

You will have to change
your
this.total + itemCost = this.total;
into
this.total = itemCost + this.total;


#3

Also these lines where you call scans like this

scan("eggs");

all must be

cashRegister.scan("the item");

You can also play round with it here
Click here to go to Labs