Forum Discussion
Javascript Math.pow
Basically this is the script you need...// connect with Storyline Player
let player = GetPlayer();
//Get the variables NetFig and NetPower
let nFig = player.GetVar("NetFig");
let nPow = player.GetVar("NetPower");
// Do the calculation and set a variable to it
let endRst = Math.pow(nFig, nPow);
// Set the Storyline variable to it, so it shows in Storyline
player.SetVar("EndResult",endRst);
A few caveats to watch when implementing it. The vars NetFig and NetPower are numbers in Storyline. I added numeric inputs for them. If your variables are Strings...well you have to convert them to Numbers first.
Further is there the dreaded often despised internal functionality that Storyline ( still ! ) limits numeric values to 2 digits. Do try and input NetFig = 7 and NetPower = -2. You get 0.02 whereas it should be 0.02040816326530612. You can solve this by showing the endresults as Strings because internally both Storyline and Javascript do the calculation correct, but somehow numeric values get limited to 2 decimals when showing in Storyline.
And here you can test it...
https://360.articulate.com/review/content/d714fde1-7952-4530-8993-afc2c23e1b55/review