Forum Discussion
CarrieEaton
2 years agoCommunity Member
Formatting numeric variables....
Friends, it's been a number of years since I asked how to format numeric variables, ie commas and decimal place such as $17,200.
Has there been any progress on this in SL after all these years? Or...
Jürgen_Schoene_
2 years agoCommunity Member
with modern javascript it is not very complicated
part 1: converting the number (based on country code + currency)
function formatCurrency(inNumber){
return new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
}).format(inNumber);
};
part 2: connection to storyline variables
var player = GetPlayer();
var input = player.GetVar("NumericEntry");
var output = formatCurrency(input);
player.SetVar("FormatedEntry", output);
result:
https://360.articulate.com/review/content/3da26422-ecc6-4cbf-a097-e74bcad9924b/review
more infos: