I don't know where the problem is?


#1

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

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

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

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

    case "chocolate" : 
        this.add(0.45);
        break;
    }
    return true;
}

};

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

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


#2

Which problem?


#3

Oops, try again. There was a problem with your syntax.
short term memory


#4

If you run it over at repl.it (node.js environment) you'll get a line number with that error message.
You can also run it in your browser, how depends a bit on the browser.
Or temporarily remove parts of your code, when there's no longer a syntax error, that means you just removed the offending code.


#5

ok tx ill try it .than ill tell you what wrong with it


#6

It kind of stands out with a bit of practice. It just wouldn't do any good to say where it is - better to show how you can solve the problem yourself!

give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime


#7