Javascript examples for String Operation:String Parse
Parse String to float and format with two decimal
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w . ja v a 2s . co m function roundNumber() { let myNumber = '0.256789'; return parseFloat(myNumber).toFixed(2); } document.write(roundNumber()); } </script> </head> <body> </body> </html>