4. I Have to Scan It More Than Once?


#1


I cannot find any errors at all. I think it might be connected to the "quantity" in some way since the error message tells about it. But I cannot figure it out. Can anyone find the error in my code and why is it wrong?


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


Oops, try again. It doesn't seem like your 'quantity' actually works!


var cashRegister = {
    total:0,
    add: function(itemCost){
        this.total += itemCost;
    },
    scan: function(item, quantity) {
        switch (item, quantity) {
        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("chocolate", 4);


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


#2

Hi this line

switch (item, quantity)

just remove , quantity


I have to scan it more than once?
#3

Ah yes, of course! Thank you


#4

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