4. I have to scan it more than once?


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

I can't see the error, but it says that my doesn't actually seem 'quantity' to work. Can anyone explain to me what's the error? Thanks!


you have to change scan

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;


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.