4/7: Scan is not defined


#1

Here's my code:
var cashRegister = {
total:0,
add: function(itemCost){
this.total += itemCost;
},
scan: function(item, quanity) {
switch (item) {
case "eggs": this.add(0.98 * quanity); break;
case "milk": this.add(1.23 * quanity); break;
case "magazine": this.add(4.99 * quanity); break;
case "chocolate": this.add(0.45 * quanity); break;
}
}
};

scan("eggs", 4)
scan("milk", 4)
scan("magazine", 4)
scan("chocolate", 4)

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

I don't actually see what's wrong with it. But when I get rid of quanity on the scan function, it still says Scan is not defined, but it will say I did it. This is honestly confusing. Any help, please?


#2

Hi try to add cashRegister to scan like that in the first case..

cashRegister.scan("eggs", 4)

#3

Thank you! For some reason, I tried that before, but it still didn't work, but now it did. Anyway, thank you!


#4

Hi, you missed semicolons ;
cashRegister.scan("eggs", 4);