View Full Version : Display negative number as a positive?

12-20-2005, 07:47 PM
I have a calculated value that is negative, which I need to display in a javacript prompt as positive. In ColdFusion, there is a function called ABS(), which gives you the absolute value of the number in question, so ABS(-5) = 5. Is there something similar in javascript? If no, how would I display a negative number without it's negative sign? Again, this is only for display purposes withing an alert. Thank you for your help!

12-20-2005, 07:51 PM
Figured it out ... for search function posterity:

displayDiff = Math.abs(countDiff);

12-20-2005, 07:52 PM
JavaScript has abs too: http://www.w3schools.com/jsref/jsref_obj_math.asp