I Have to Scan It More Than Once? help!


#1


https://www.codecademy.com/courses/close-the-super-makert/0/4?curriculum_id=506324b3a7dffd00020bf661#


I dont know what's wrong with the code. I get "Oops, try again. Did you scan four of each item?" as the error message.


var cashRegister = {
    total:0,
    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;
        case "magazine": this.add(4.99 * quantity); break;
        case "chocolate": this.add(0.45 * quantity); break;
        }
    }
};

// scan each item 4 times
cashRegister.scan('eggs', 4);
cashRegister.scan('milk', 4);
cashRegister.scan('magazine', 4);
cashRegister.scan('chocolae', 4);

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


#2

Check last scan() method call's arguments.

also

add: function(itemCost,)

why put comma there ?


#3

thanks a lot ! I was stuck there for over an hour just because of some typos


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.