Skip to content

Instantly share code, notes, and snippets.

View christianberkman's full-sized avatar

christianberkman

  • Uganda
  • 23:12 (UTC +03:00)
View GitHub Profile
@christianberkman
christianberkman / amountToFloat.js
Last active October 19, 2022 19:39
Create float from unkown currency amount in unkown format
/*
This function will take (almost) any string representing a monetary amount and parse it correctly as a float.
Thousand seperator can be '.' or ','
Decimal point can be '.' or ','
Currency symbols etc. will be removed
The following strings will all parse to (float) 1250.99:
1250.99
1,250.99
1.250,99
€1.250,99