4/7 The code works but it is rejected by the system


#1


I do not know why the system throws error since the expected output works.

Thanks in advance gang! :slight_smile: appreciate it!

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) {
        case "eggs": this.add(0.98 * quantity); break;
        case "milk": this.add(1.2 * 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

@rjbrabante,
Try it with a milk-price of 1.23


#3

Thanks Man!!! :slight_smile: Ughh... This is such a perfectionist system, silly me..