need a javascript and explanation
Nov 26, 2012
Hi,
I have a number that I need to convert to a integer (no decimal places) from a calculations. Perhaps I have taken the long way to do this so I am looking for helpful advise.
basically I use the following variables:
totalScore (this adds up all the results from the various variables in the questions)
totalPossible (thisĀ is set to 285)
totalPercent (the result of the calculation)
I set totalPercent to totalScore on load
divide totalPercent by totalPossible
this results in as example 28.54
what I need is to round 28.54 to an integer (29)
I think my javascript is off so if anyone can provide an example I would be so appreciative
var player=GetPlayer();
var totalPercent=player.GetVar("totalPercent");
var mathround=Math.round("totalPercent");
1 Reply
You're really close, Shawn. Just need one more line to push back into Storyline:
var player=GetPlayer();
var totalPercent=player.GetVar("totalPercent");
var mathround=Math.round("totalPercent");
player.SetVar("totalPercent",mathround);
That should get it.
This discussion is closed. You can start a new discussion or contact Articulate Support.