3/7 ReferenceError: total is not defined


#1

All right. So it says on the console "ReferenceError: total is not defined", but i don't understand why. Here's my code:

var cashRegister = {
    total: 0,
//insert the add method here    
    add: function(itemCost) {
        itemCost += total
    },
    
    scan: function (item) {
        switch (item) { 
        case "eggs": 
            this.add(0.98); 
            break;
        
        case "milk": 
            this.add(1.23); 
            break;
        
        //Add other 2 items here
        case "magazine":
            this.add(4.99);
            break;
            
        case "chocolate":
            this.add(0.45);
            break;
        }
        return true;
    }
};

//Scan 2 eggs and 3 magazine
cashRegister.scan("magazine")
cashRegister.scan("magazine")
cashRegister.scan("magazine")
cashRegister.scan("chocolate")
cashregister.scan("chocolate")
//Show the total bill
console.log('Your bill is '+cashRegister.total);

#2

try changing the chocolate to egg in cashRegister.scan


#3

Try switching your total and item cost. So this.total += itemCost.

This will work OP...