Is there a math function in JavaScript that converts numbers to positive value?

You could use this...

Math.abs(x)

http://stackoverflow.com/questions/4652104/convert-a-negative-number-to-a-positive-one-in-javascript