Part: Short-Term Memory Error


#1

" SyntaxError: Unexpected token " is what I am getting. Seems like it breaks when I create the "Add" function, but I dont see anything wrong with it. I even copied and pasted from the previous tutorial to see if it is a dumb typo.

Thank you for your time.


#2

It's either that I'm blind or stupid, but I don't seem to find a problem on your syntax.

Tried refreshing the browser?:smiley:


#3

I'm so glad it is not me then lol. II will try doing that when I get back on. I'd hate to spend 20 bucks just so I can talk to someone about a bug that might exist. Thanks for thereply. :smile:


#4

Completely deleted all cookies and cache from Chrome, and even tried it on internet explorer. IE tells me that Im missing a '}' and chrome doesn't mention that. Either we're both blind, or there is a problem on their website. Its a shame too, I am at 97% completion.


#5

Welp, apparently there needs to be a comma after the first function. I apologize for assuming it was a website error when the true fault was user error. Thank you for the time you put into trying to figure it out.


#6

Sorry, I couldn't get on in time... :smile:

But congrats on almost being done with the course!


#7

Hey can someone tell me whats wrong with this one?
var cashRegister = {
total: 0,
//insert the add method here
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);

I am getting this message: SyntaxError: Unexpected identifier 'scan'. Expected '}' to end a object literal.


#8

Ok I got it.
Coma after function like this
add: function (itemCost) {
this.total+=itemCost;
},