Why the order of the parameters of 'scan' method actually matters?


#1

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

But it does actually work. And the result is actually correct:

var cashRegister = {
    total:0,
add: function(itemCost){
    this.total += itemCost;
},
scan: function(quantity, item) {
    switch (item) {
    case "eggs": this.add(0.98 * quantity) ; break;
    case "milk": this.add(1.23 * quantity); break;
    case "magazine": this.add(4.99 * quantity); break;
    case "chocolate": this.add(0.45 * quantity); break;
    }
}
};

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


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

So, why doesn't it accept this answer?


#2

div class="learn-more">



Travel


...
<div>
  <h3>Host</h3>
  ...
</div>

<div>
  <h3>Trust and Safety</h3>
  ...
</div>