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.