3/7 Short Term Memor


#1

This is my code. Cannot understand why the interpreter says "Oops, try again. Have you scanned eggs twice and magazine three times?". Help please! Thanks :slightly_smiling:


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 "chocolate":
        this.add(4.99);
        break;
    case "magazine":
        this.add(0.45);
        break;
    }
    return true;
}

};

//Scan 2 eggs and 3 magazines
cashRegister.scan("eggs");
cashRegister.scan("magazine");
cashRegister.scan("eggs");
cashRegister.scan("magazine");
cashRegister.scan("magazine");

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


#2

@shuvamnandi,
Use the correct the price's for the "magazine" and "chocolate" items


#3

those are the correct prices, or what are you talking about??? i have the same issue, i have no syntax, neither a semantic error, like wrong prices(according the task description) and it still gives me the wrong amount of eggs/magazines error message :\


#4

Well in the above case it looks as though the prices of chocolate and magazine were switched. "chocolate" is (0.45) and "magazine" is (4.99)