I want to convert the string “15,678” into a value 15678. Methods parseInt() and parseFloat() are both returning 15 for “15,678.” Is there an easy way to do this?
I want to convert the string 15,678 into a value 15678. Methods parseInt() and
Share
The simplest option is to remove all commas:
parseInt(str.replace(/,/g, ''), 10)