4. I Have to Scan It More Than Once? Please can you provide assisstance


#1



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


Hi it says my quantity doesn't work even thought it says your total is 7.65. Can you please explain what is wrong? :confused: :grin:


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

There are two arguments given in the above. The item and the quantity. However,

there is only one argument accepted by the method. Try adding a quantity parameter, as well.

    scan: function ( item, quantity ) {

so that this,

becomes,

case "eggs": this.add(0.98 * quantity); break;

#3

ok thx I got real confused there


#4

Did you learn something to take away from this?