-
Change dot to comma in expression
I have a expression that makes a dot every 3 digits: 1.000
I want to change the dot to comma with a drop down menu.
If the dropdown menu value is 3 or 4 change to comma: 1,000
How can I do that with this expression:
var num = Math.floor(effect(“Number”)(“Valor”).value)
var num = Comma(num);
var menu = effect(“Number”)(“Dot and Comma”).value;
function Comma(number) {
number = ” + Math.round(number);
if (number.length > 3) {
var mod = number.length % 3;
var output = (mod > 0 ? (number.substring(0,mod)) : ”);
for (i=0 ; i < Math.floor(number.length / 3); i++) {
if ((mod == 0) && (i == 0))
output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
else
output+= “.” + number.substring(mod + 3 * i, mod + 3 * i + 3);
return (output);
else return number;