3. Short Term Memory Need Help


#1



Oops, try again. Have you scanned eggs twice and magazine three times?


Replace this line with your code. 
var cashRegister = {
    total: 0,
//insert the add method here    
    add: function(itemCost){
        this.total += itemCost;
    },
    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 magazines
casgRegister.scan ("eggs");
casgRegister.scan ("eggs");
casgRegister.scan ("magazine");
casgRegister.scan ("magazine");
casgRegister.scan ("magazine");
//Show the total bill
console.log('Your bill is '+cashRegister.total);


#2

look at the error message in the output window:

ReferenceError: casgRegister is not defined

you made a typo in cashRegister (several times)


#3

OMG SO SORRY >.< i dont know how i missed it even after for looking like 20 minutes, i was finding mistake in syntax.


#4

No need to apologizes, such mistakes are easily made (been there, done that, more times then i would like to admit :stuck_out_tongue: )

I also showed you how i approached the problem, hope that helps you as well


#5

thanks :smile: :smile:


#6