Building a cash Register.!


My code below obviously works, but this ‘not so smart’ engine of yours doesn’t recognize it and for that reason I cannot move on… already tried in Chrome and Opera and I will not install another browser to solve this.

var cashRegister = {
    add: function(itemCost){ += itemCost;
    scan: function(item, quantity) {
        while (quantity > 0) { 
            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;

// scan each item 4 times
cashRegister.scan('eggs', 4);
cashRegister.scan('milk', 4);
cashRegister.scan('magazine', 4);
cashRegister.scan('chocolate', 4);

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


Your bill is 30.6


please share exercise url, this seems to be the old course which is no longer supported


here is the URL.

But I don’t really understand, if it is not supported anymore, why is it still active? it is true that I followed an older link from a document, but since it was working, I assumed it should be fine. Now that I think about it, it is old since it doesn;t support ‘let’ or ‘const’ declarations.


i don’t know, personally, i think it should just be taken down

i do recommend updating the latest supported courses which can be found on the main site

The exercise doesn’t approve of using a loop, you need to simply multiply the price (for example .45 for chocolate) with quantity when calling add, its also more efficient then your while loop


well that solves the problem then and I do agree that this solution is more efficient. that was the one that came to mind at that point. I will try and follow the more recent courses.

Thanks for your time and effort!