4- Codes works, test thinks otherwise



"Oops, try again. It doesn't seem like your 'quantity' actually works!"

Well, the code returns the desired results. I'm not sure how it wants me to do this.
I guess a for loop isn't cool for adding things a set number of times?
I wondered if it wants me to add a product of quantity and cost to total instead (which seems counter-intuitive for a register, instead of just adding.)

anyway, here is the code. It logs the correct sum to the console, and works over on repl.it as well

var cashRegister = {
    add: function(itemCost){
        this.total += itemCost;
    scan: function(item,Qty) {
        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

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


Sometimes you have to follow the instructions perfectly. You've abbreviated 'quantity' so the despite your syntax being correct, you've not followed the instructions.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.