Forum Discussion
KimGabites
4 years agoCommunity Member
Help with Java Script to format numbers
Hi everyone
Thank you for the awesome help on my last query around the characters. I have a new challenge I am hoping someone expert in java-script can help me with please. I am brand new to it, s...
KimGabites
4 years agoCommunity Member
Hi Math
The script brought up the dollar sign but it didnt put in any commas. What is the script for putting in commas as well please?
Cheers
Kim
var player=GetPlayer();
varTotAvailSav=playerGetVar("TotAvailSav");
varTotAvailSav=TotAvailSav.toFixed(0).replace(/\d(?=(\d{3})+\.)/g, '$&,');
vartxtvalue=TotAvailSav.toString();
player.SetVar("txtTotAvailSav",txtvalue);
MathNotermans-9
4 years agoCommunity Member
Im not quite sure what's the issue. Might be the regex replace that removes all comma's .... my Regex is not that good. Whats supposed to happen ?
Here you can construct and test any Regex you want.
https://regex101.com/
Related Content
- 10 months ago
- 8 months ago
- 5 months ago
- 2 months ago