4/7 Code passes, output is incorrect


#1

I dont know what's wrong with it.

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.23) *= 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

What is your output that you're getting that's incorrect?


#3

This would be the thing prints out on the output;
"ReferenceError: Invalid left-hand side in assignment"


#4

I see the problem now.

case "eggs": this.add(0.98) *= quantity; break;
 case "milk": this.add(1.23) *= quantity; break;
 case "magazine": this.add(4.99) *= quantity; break;
 case "chocolate": this.add(0.45) *= quantity; break;

change all of these to look a little like this:

this.add(0.98, quantity);

You're utilizing the "add: function" to do the multiplication for you.


#5

I think the correct code Is:
this.add(0.98*quantity); break;
In the scan part:
cashRegister.scan("eggs",4);


#6

Thanks I got it, just removed the equal sign " = " beside the multiplication sign " * " and place the "quantity" inside the parenthesis.