i want convert my string into number
var string = '1234'
var check = Number(string);
console.log(check);
but if i give my string like below, it wont convert correctly.
var string = '1,234'
var check = Number(string);
console.log(check);
Is there any alternate available?
You have to remove all the non numeric characters from string for this to work.
var string = '1,234'
var check = Number(string.replace(',',''));
console.log(check);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With