to calculate the absolute value of num. in JavaScript

 function doMath(){
        var inputNum=document.form1.input.value;
        var result = Math.abs(inputNum);
        document.form1.answer.value = result;
    }