Bleep Bleep-lost about cashRegister.voidLastTransaction();


The code is right, but I do not understand why after calling cashRegister.voidLastTransaction(); I get the last item subtracted. And why this.lastTransactionAmount = itemCost; ?

Replace this line with your code.


lets start at add:

    add: function(itemCost) { +=  itemCost;
        var lastTransactionAmount = itemCost;

you give lastTransactionAmount the value of item cost, so you have a variable which holds the last transaction amount. if you have the last transaction amount you can simply subtract it from total:

VoidLastTransaction: function() { =  - this.lastTransactionAmount

in case of a wrongly scanned item.


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