Open luckman212 opened 3 years ago
Yeah, should be able to do that. I'll take a look next time I have that code open.
Ah, ran into a hitch here. I can't blindly ignore commas because in some locales they are used instead of decimal points. That makes this a bit trickier. It looks like there is a native way to format numbers to the current locale, but not parse them. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
Hmm, I see. What about adding a setting box where the user can input a "character to ignore" (simpler than trying to work this out automatically based on the num format or their regional settings etc).
I haven't looked yet at the code but if the function just runs a str.replace(/char/g,"")
to strip them before performing the math—could that work?
should you go the "settings" way (adding characters to ignore), maybe also add a setting allowing the user to select what a decimal "point" is 🙈 (for me it's a comma 😆)
This may be a hard limitation but, I was wondering, is it somehow possible to support math e.g.
sum()
functions when the numbers contain commas? E.g. see below:result:
(should be 2607)