Prev Demo
Formatting The Different Lengths Of Same Number
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Formating same number into different lengths.</h1> <p>Click the below button to format into 3 digit specified length</p> <input type="button" value="Format" onclick="Function()" /> <p id="myId"></p> <script> function Function() { var a = 1.74562; var r =a.toPrecision() + "</br>" + a.toPrecision(1) + "</br>" + a.toPrecision(2) + "</br>" + a.toPrecision(3) + "</br>" + a.toPrecision(4) + "</br>" + a.toPrecision(5) + "</br>" + a.toPrecision(6) + "</br>" + a.toPrecision(7) + "</br>" ; document.getElementById("myId").innerHTML = r; } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output