

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I format numbers as dollars currency string in JavaScript?
To format numbers as dollar current string, use number formatter, which is part of the Internationalization API.
Example
You can try to run the following code to format numbers as dollars currency string
<!DOCTYPE html> <html> <body> <p> Formatting 150 as US dollars (US$): </p> <script> var formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 2, }); // for 150$ document.write(formatter.format(150)); </script> </body> </html>
- Related Questions & Answers
- What should I do? Select int as currency or convert int to currency format in MySql?
- Format currency with Java MessageFormat
- Converting numbers to Indian currency using JavaScript
- How can I eliminate numbers in a string in Python?
- How to use Bitcoins as Traditional Currency?
- How can I convert 'HH:MM:SS ' format to seconds in JavaScript
- Can I declare JavaScript variables as specific types?
- C# Currency ("C") Format Specifier
- How can I represent python tuple in JSON format?
- How can I store the fixed length string as well as variable length string in the same MySQL table?
- How to format JSON string in JavaScript?
- How can I convert a string to boolean in JavaScript?
- How do I display the content of a JavaScript object in a string format?
- How to get string as date in MySQL with dates as dot format specifier?
- How I can dump a Python tuple in JSON format?
Advertisements