Bleep Bleep Help


Hey, I really can't figure out where I'm going wrong here. Can someone tell me where I'm messing this up? It says "SyntaxError: missing : after property id".

var cashRegister = {
    this.lastTransactionAmount = itemCost
    add: function(itemCost) { +=  itemCost;
    scan: function(item,quantity) {
        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;
        return true;
    voidLastTransaction: function() {
     return -= lastTransactionAMount 
     this.lastTransactionAmount = 0;


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


Error messages usually come with line numbers for what was being executed at the time of the error, that's left out in the js lessons for whatever horrible reason, can't imagine there's a good one.

Here's what it looks like if I run your code on my machine with nodejs:

$ node potato654.js 
    this.lastTransactionAmount = itemCost
SyntaxError: Unexpected token .

Your browser is also able to run js code, I know firefox has a scratchpad (shift f4), chrome might be a bit tricker
or install nodejs
or run it in some online interpreter

And those should all give you more verbose error messages if you should need it

In this case nodjs actually found a different problem first and reported that instead.


Thanks for the resource to check out. When I looked at the error message on Firefox's scratchpad it gave me an error of "Exception: SyntaxError: missing : after property id @Scratchpad/1:3" Honestly, I'm not really sure of what's wrong in line 3 though. I've added a colon to that line in all of the places that it could matter and it's still not working. Wat do? :sweat:


Compare to the line above/below, what do they do with colons?


Alright I figured it out, thanks for the help. :relieved:


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