-
Update expression for newer JavaScript engine?
Anyone can help to update this expression to work with the newer expression engine? It works fine with legacy but then some other expressions in different parts of my project stop working.
Thanks in advance.
Btw, this expression is to create a counter that goes into the thousands and automatically adds a comma and places it in the correct location.
—————-
var num = thisComp.layer(“xp”).effect(“counter”)(“Slider”);
num = Comma(num);
[num]
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;
}