Forum Discussion
KevinMcGrath
2 years agoCommunity Member
javascript not working
Hi,
I'm running the following JavaScript but it doesn't work (variable stays at 0)
Can anyone tell me where I've gone wrong?
let player = GetPlayer();
let num1 = player.GetVar(“Total_Money”);
let num2 = player.GetVar(“COUNT_employees”);
let result = Math.(num1/num2);
player.SetVar(“Ave”, result);
Many thanks
- Jürgen_Schoene_Community Member
let result = Math.(num1/num2);
"Math." is the problem - it is only the first half of the function name
if you want to round to an integer, the function is Math.round( ... )
- KevinMcGrathCommunity Member
Thanks so much! Got it working. It also wasn't recognising things with "..." so I swapped to '...' and swapped let to var and it's working correctly now. So happy. Thank you!