I Have to Scan It More Than Once?


#1



what's wrong with my code? does anybody knows? thank you for support

ReferenceError: quantity is not defined


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

cashRegister.scan("eggs", 4);
cashRegister.scan("milk", 4);
cashRegister.scan("magazine", 4);
cashRegister.scan("chocolate", 4);

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


#2

you added a quantity parameter to the scan method. this means the multiplication of item price times quantity should be done in your scan method, not your add method


#3

thanks a lot! realize it


#4