Short term memory --- "Oopss" message counts too many scans


Short term memory, no syntax errors, but all possible items scanned again
after printing out total!

So I get an "Oops message because one too many eggs, magazines and chocolates are counted as scanned" --- does my code somehow manage to show up a bug in the codeacademy analysis code?

Very odd behaviour, doesn't happen when I run it through rhino

Code is

var cashRegister = {
    total: 0,
//insert the add method here   

     add: function(cost){;
        console.log("In add function");
      },    //DONT FORGET THE COMMA!
     scan: function (item) {
        switch (item) { 
        case "eggs": 
                        console.log("Added " +item);
        case "milk": 
                        console.log("Added " +item);
        case "magazine": 
                        console.log("Added " +item);
        case "chocolate": 
                        console.log("Added " +item);
            console.log("Item not found in price list --- not adding!");
        }   //end switch  
         console.log("Item scanned  was", item);
        return true; 

        } //end scan function

};  //end constructor

var retval=false;
console.log("scans begin");
console.log('running total is ';
console.log('running total  ';
console.log('running total  ';
console.log("scans end");

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


Oh dear, I misread the error message "Have you" as "You Have", and misremembered the items to scan.

However, if I generate the "Oops" message, it still calls the add function for each possible item
after all the all calls to scan are completed --- which confused matters even more...


Hi seagods, is your progblem solved? If not, please explain it clearly. Thanks!


So,my end of the problem is solved, all I had to do was put in the right items to scan. The most confusing bit though was that the codeacademy software scans each item after the 'Your bill is' statement for each case in the switch. So I seem to have something to throw the codeacadamy analysis code a bit?


Maybe this is related?