3. short-term memory


#1

its giving me the syntaxerror: unexpected token :,
cn anyone tell me why?
thank you.

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
cashRegister.scan("eggs");
cashRegister.scan("eggs");
cashRegister.scan("magazine");
cashRegister.scan("magazine");
cashRegister.scan("magazine");
//Show the total bill
console.log('Your bill is '+cashRegister.total);


#2

Inside of an object, if you are adding other variables/functions/objects, you separate them with a comma. The last added value should not have anything after it (no semicolon or comma).


#3

Thanks ropnog, I had the same problem as above.
The instructions on the left-hand side tell me there needs to be a semicolon ; after closing the "add" function, but it will only work with the comma.