3/7 Not sure where my error is?


#1

I'm not too good with js tbh i will probably redo the whole course once finished as i'm not the fastest of learners so all help and explanation will be useful thank you.

var cashRegister = {
total: 0,
add: function(itemCost){
this.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");

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


#2

You accidently put a bracket at line 5. Delete that bracket and then on the bracket before that put a comma, so it continues and that should be it! It was just a syntax error! I reccomend you do the javascript course all over again or go to this website. Its an awesome!!! Tutorial! Hope this helped you!


#3

Thank you buddy i appreciate the feedback