-1

How could I transform a number with commas like 123,245 to a number without commas like this 123245, I know that you could already put commas in number without them but how to do that in reverse? pure JAVASCRIPT please!

badu fasil
  • 25
  • 4

2 Answers2

0
var number = Number("123,456".split(",").join(""));

Or:

var number = parseInt("123,456".split(",").join(""));
RomanY
  • 376
  • 2
  • 9
0

An alternative is using a regex /,/g

console.log("123,245".replace(/,/g, ''));
console.log("123,245,566".replace(/,/g, ''));
Ele
  • 33,468
  • 7
  • 37
  • 75