I have a simple, but perplexing problem, with Math.
The following code will take a number from a string (usually contained in a span or div) and subtract the value of 1 from it.
.replace(/(\d+)/g, function(a,n){ return (+n-1); });
This works really well, except when we get below zero. Once we get to -1 we're obviously dealing with negative subtraction.
-1 - 1 = -0
-0 - 1 = --1
how can I avoid this? It's likely I've got a general problem with the math here.