Number toPrecision()
The toPrecision() method returns either the fixed or the exponential representation of a number. This method takes the total number of digits to represent the number as the argument.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var num = 99;
document.writeln(num.toPrecision(1)); //"1e+2"
document.writeln(num.toPrecision(2)); //"99"
document.writeln(num.toPrecision(3)); //"99.0"
</script>
</head>
<body>
</body>
</html>