Uncaught SyntaxError: Invalid or unexpected token

Uncaught SyntaxError: Invalid or unexpected token
0

#1

I’m using eval on a simple arithmetic string as part of the calculator project. The trouble is, whenever I use subtraction, I get an Uncaught SyntaxError: Invalid or unexpected token error. What’s driving me crazy is if I take the string that was being evaluated (output using console.log) and pass it to eval in a REPL, it works fine.

Does anybody have any idea what’s causing this? Here’s a link to the CodePen.


#2

change the char in your html to from to -


#3

Thanks! How did you manage to track it down? It was driving me crazy.