Check out this link.. It helped me a lot.
http://www.w3schools.com/jsref/jsref_toprecision.asp
The toPrecision(no_of_digits_required)
function returns a string
so don't forget to use the parseFloat()
function to convert to decimal point of required precision.