Prev Demo
Converting A Number Into A String Keeping Only One Decimal
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Convert a number into a string, keeping only one decimal</h1> <p>Click the below button to convert a number into a string by keeping only one decimal.</p> <input type="button" value="Convert" onclick="Function()" /> <p id="myId"></p> <script> function Function() { var A = 2.79562; var R = A.toFixed(1) document.getElementById("myId").innerHTML = R; } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output