loading...

re: Daily Challenge #276 - Unwanted Dollar Signs VIEW POST

TOP OF THREAD FULL DISCUSSION
re: This is my solution in javascript: const money_value = (str) => parseFloat(str.replace('$','').replace(' ','')); A more readable version: ...
 

My solution in Typescript

const remove_dollar = (input: string) => Number(input.replace(/\$|\s/g, ""));
 

I like this but I will do it without /g as you will encounter this replacement at the most once. Also space after $ maybe present or may not be so /\$?\s?/ would do I guess. What do you think?

Code of Conduct Report abuse