Help me please 5/7


#1

What's wrong with this code???

var cashRegister = {
 total:0,
 lastTransActionAmount:0,
 add: function(itemCost) {
 this.lastTransactionAmount = itemCost;
 this.total += itemCost;
 },
voidLastTransaction: function() {
 this.total -= this.lastTransactionAmount;
 }
var cashRegister = {
 total:0,
 lastTransActionAmount:0,
 add: function(itemCost) {
 this.lastTransactionAmount = itemCost;
 this.total += itemCost;
voidLastTransaction: function() {
 this.total -= this.lastTransactionAmount;
 }
 },
cashRegister.scan('eggs',1);
cashRegister.scan('milk',1);
cashRegister.scan('magazine',1);
cashRegister.scan('chocolate',4);
cashRegister.voidLastTransaction();
cashRegister.scan('chocolate',3);
console.log('Your bill is '+cashRegister.total);

#2

What is the error message you receive?

PS: Ok from what I can see on first view is that you overwrite your object by an object almost the same and messed up your {} in the progress. Why do you create two cashRegister variables in the first place?


#4

the error message is:

Oops, try again. There was a problem with your syntax.
SyntaxError: Id wordt verwacht

and I don't know why I have create two cashRegister variables. I removed the first one


#5

Also in the second one you messed up some of the {}:

var cashRegister = {
... 
add: function(itemCost) {
    this.lastTransactionAmount = itemCost;
    this.total += itemCost;
   voidLastTransaction: function() {
       this.total -= this.lastTransactionAmount;
   }
 },

currently voidLastTransaction is part of add an the object is not closed.