To remove the commas, you’ll need to use replace
on the string. To convert to a float so you can do the maths, you’ll need parseFloat
:
var total = parseFloat('100,000.00'.replace(/,/g, '')) +
parseFloat('500,000.00'.replace(/,/g, ''));
More Related Contents:
- Build an HTML table using React from arrays [closed]
- Does an array contain a specific item? [duplicate]
- How to change the image while sharing the content to the social networks? [duplicate]
- Can a website detect when you are using Selenium with chromedriver?
- Does JavaScript pass by reference? [duplicate]
- How to distinguish between left and right mouse click with jQuery
- How to get the difference between two arrays of objects in JavaScript
- Difference between setTimeout with and without quotes and parentheses
- How to delete an item from state array?
- Why doesn’t my equality comparison using = (a single equals) work correctly? [duplicate]
- How exactly does work?
- Reading client side text file using Javascript
- How do I access an access array item by index in handlebars?
- javascript regular expression to check for IP addresses
- How to set background color of HTML element using css properties in JavaScript
- How can I set response header on express.js assets
- Comparing two times with Moment JS
- Grasping prototypical Inheritance through pseudoclassical instantiation (JavaScript)
- How do you save an image from a Three.js canvas?
- update cloud firestore document without id
- AngularJS: How do I manually set input to $valid in controller?
- Mongoose: Find, modify, save
- Create thumbnail from video file via file input
- Reading non-inline CSS style info from Javascript
- How to Call a Function inside a Render in React/Jsx
- Javasacript Countdown timer in Days, Hours, Minute, Seconds
- XML parser for JavaScript [closed]
- return AJAX callback return [duplicate]
- D3.js: Position tooltips using element position, not mouse position?
- React Functional component: calling as function vs. as component