
- 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 to convert a currency string to a double with jQuery or JavaScript?
To convert a currency key, use the replace() and within that set REGEX.
Example
Following is the code −
var euroCurrenyValue = "€55,600.35"; var result = Number(euroCurrenyValue.replace(/[^0-9.-]+/g,"")); console.log(result); var dollarCurrenyValue = "$645,345.50"; var result1 = Number(dollarCurrenyValue.replace(/[^0-9.-]+/g,"")); console.log(result1);
To run the above program, you need to use the below command −
node fileName.js.
Here, my file name is demo324.js
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo324.js 55600.35 645345.5
- Related Questions & Answers
- MongoDB query to convert a string with commas to double
- How to Convert Double to String to Double in Java?
- How to convert a double value to String in Java?
- How to convert a Double array to a String array in java?
- Convert a String to a double type number in Java
- Convert double to string in Java
- Convert String to Double in Java
- Java Program to convert String to Double
- Java methods to convert Double to String
- How to convert a double value into a Java String using append method?
- How to convert a double value into a Java String using format method?
- How to convert a string with zeros to number in JavaScript?
- How to convert a string to JavaScript object?
- JavaScript function to convert Indian currency numbers to words with paise support
- How do I convert a double into a string in C++?
Advertisements