Since parseInt/parseFloat will return NaN on a non-numeric string, the regex here doesn't seem necessary. Can you explain this change?

Also, brackets.