Short Term Memory


#1

I got error message "Have you scanned eggs twice and magazines three times? Here's my code below:

var cashRegister = {
total: 0,
add: function (itemCost) {
this.total += itemCost;
}, //insert the add method here

scan: function (item) {
    switch (item) { 
    case "eggs": 
        this.add(0.98); 
        break;

    case "milk": 
        this.add(1.23); 
        break;

    case "magazine":
        this.add(4.99);
        break;
    case "chocolate":
        this.add(0.45);
        break;//Add other 2 items here


    }
    return true;
}

};

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

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


#2

Hey @spaceinvad0r! Its just a type. its suppose to be magazine instead of magazines.

So replace all this:

cashRegister.scan("magazines");

with this:
cashRegister.scan("magazine");

Hope this helped and

Have a Merry Christmass :evergreen_tree: :- )


#3

argh?! lol gosh coding can make ya feel like a fool shanks!


#4

hmmmm, i just changed them all. my bill is 14.97 but im still getting that message =/


#5

Try editing your scanning code to this:

cashRegister.scan("eggs")
cashRegister.scan("eggs")
cashRegister.scan("magazine")
cashRegister.scan("magazine")
cashRegister.scan("magazine")

#6

thank you!!! it finally worked!