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



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 = {
    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);


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,


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


ok thx I got real confused there


Did you learn something to take away from this?