4/7 I have to Scan more then once?


var cashRegister = {
    add: function(itemCost){
        this.total += itemCost;
    scan: function(item) {
        switch (item,num) {
        case "eggs": this.add(0.98*this.num); break;
        case "milk": this.add(1.23*this.num); break;
        case "magazine": this.add(4.99*this.num); break;
        case "chocolate": this.add(0.45*this.num); break;

// scan each item 4 times

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


What is this this.num where does it come from? Your cashRegister object doesn't have a num property. Also scan takes 1 argument and you give it 2, so the second is ignored. And finally this is not how switch works, better review it. Switch has one value in its () and compares this value to the values mentioned after the case keywords.