4/7: Scan is not defined


Here's my code:
var cashRegister = {
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?


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

cashRegister.scan("eggs", 4)


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


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