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

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading