Reputation: 941
When trying to convert a string to number in a browser console:
let a="3,437,286"
+a
returns NaN
. Do you see what am I missing here?
Upvotes: 0
Views: 258
Reputation: 167172
That string isn't a proper number. Maybe if the string always has numbers with commas, you can remove the commas and try to check it:
let a = "3,437,286";
console.log(+a); // NaN
console.log(+a.replace(/,/g, "")); // 3437286
Upvotes: 1