5. Bleep Bleep Error


#1


5. Bleep Bleep


ReferenceError: lastTransActionAmount is not defined

Oops, try again. It looks like you have an error in your code! Check the error message for more details: ReferenceError: lastTransActionAmount is not defined


Replace this line with your code. 
var cashRegister = {
    total:0,
    lastTransactionAmount:0,
    //Dont forget to add your property
    add: function(itemCost) {
        this.total +=  itemCost;
        this.lastTransactionAmount += 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;
        }
        return true;
    },
    //Add the voidLastTransaction Method here
    voidLastTransaction: function() {
        lastTransActionAmount -= total;
    }
    
};

cashRegister.scan('eggs',1);
cashRegister.scan('milk',1);
cashRegister.scan('magazine',1);
cashRegister.scan('chocolate',4);

//Void the last transaction and then add 3 instead
cashRegister.voidLastTransaction();
cashRegister.scan("chocolate", 3);

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


#2

Check the spelling. The variable also needs a context, this.lastTransactionAmount.

Another point of contention:

We don't wish for this to accumulate, but be set anew each time.

... = itemCost

#3

When I apply those changes now it says "ReferenceError: total is not defined" and "Oops, try again. It looks like you have an error in your code! Check the error message for more details: ReferenceError: total is not defined"


#4

That would be this line (this.total is defined, but total is not)...

We don't want to subtract the total from the last transaction, but the reverse.

this.total -= this.lastTransactionAmount

#5

thx so much bro ham ham ham


#6

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