- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Converting numbers to Indian currency using JavaScript
Suppose we have any number and are required to write a JavaScript function that takes in a number and returns its Indian currency equivalent.
toCurrency(1000) --> ₹4,000.00 toCurrency(129943) --> ₹1,49,419.00 toCurrency(76768798) --> ₹9,23,41,894.00
Example
The code for this will be −
const num1 = 1000; const num2 = 129943; const num3 = 76768798; const toIndianCurrency = (num) => { const curr = num.toLocaleString('en-IN', { style: 'currency', currency: 'INR' }); return curr; }; console.log(toIndianCurrency(num1)); console.log(toIndianCurrency(num2)); console.log(toIndianCurrency(num3));
Output
And the output in the console will be −
₹1,000.00 ₹1,29,943.00 ₹7,67,68,798.00
Advertisements