5/7 Get 8.55 but can't proceed?


Not sure what I'm doing wrong? I get the right output - 8.55, but also an error message saying "Oops. Try again. False.) Any help appreciated!

var lastTransactionAmount = 0;
var cashRegister = {
//Dont forget to add your property
add: function(itemCost) {
this.total += itemCost;
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(){
this.total -= lastTransactionAmount;

console.log("Your bill is "+cashRegister.total);
console.log("last transaction value: "+lastTransactionAmount);

//Void the last transaction and then add 3 instead

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


Hi maybe this will help you:

var cashRegister = {
lastTransactionAmount: 0, <-------- this is needed!
//Dont forget to add your property
add: function(itemCost) {
this.total += itemCost;
this.lastTransactionAmount = itemCost; <------ you almost got this right.

This is how the Void needs to look like:

voidLastTransaction: function(){
   this.total -= **this.**lastTransactionAmount; <---- this needs to be added.

hoop it helps.


Same problem. Got 8.55. But Oops, try again. False.


you defined an object.
var lastTransactionAmount = 0:

You should add it as a property
lastTransactionAmount = 0,


I had the same problem and I found out that I didn't write voidLastTransaction, as requested, but voidLastTransactionAmount. The code works, obviously, but the exercise isn't right. So check if you wrote everything exactly as requested, or it wouldn't work.

For example, I can see that you wrote:

but the code that will pass is:

voidLastTransaction: function(){
this.total -= lastTransactionAmount;

It's the same for the code, but not for the exercise.


did you have a solution about it?


This function works



Thank you, this helped me solve the course at last!