Skip to content

JavaScript parseFloat 2 decimal with comma | Example code

  • by

First, use the toFixed() method and then use the toLocaleString method to parseFloat 2 decimal with a comma in JavaScript.

Example parseFloat 2 decimal with comma in JavaScript

Simple example code.

<!doctype html>
  <head>

    <script>
      let n = 10200300.3963;
      let res = n.toFixed(2);

      let str = res.toLocaleString("en-US");
      
      console.log(res);


    </script>
  </head>
  <body>

  </body>
  </html>

Output:

JavaScript parseFloat 2 decimal with comma

Do comment if you have any doubts or suggestions on this JS parseFloat topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *