Get Number value from Currency format String

some time we need get the actual number value from a well formated string. this example shows how we get the exact number value.

Lets consider we have a string its value like

$1,221.22

So the actual number is 1221.22 after eliminate the Dollar sign and comma. The javascript code is -

function getNumberFromCurrencyString(currencyString){
var result = currencyString.replace(‘$’,”); //remove dollar
result = result.replace(/\,/g,”); //remove comma
return result;
}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.