JavaScript Help - Adding 5 variables to 1 for a Total Score in Storyline
Does anyone know why my JavaScript trigger isn't working in Storyline? I have 5 scenarios, each with a sectional score (ScorePessimist, ScoreExpert, etc.). I also want to show a Total Score (ScoreTotal) as learners can self-select the order in which they tackle the scenarios from a Menu. The Total Score should be the sum of all of the sectional scores.
Attempt 1) This worked and updated the ScoreTotal variable in Storyline to 10.
var player = GetPlayer();
var ScoreTotal1 = 10;
player.SetVar("ScoreTotal", ScoreTotal1);
Attempt 2) This did nothing, Total Score stayed at 0.
var player = GetPlayer();
var ScorePessimist1 = player.getVar("ScorePessimist");
var ScoreExpert1 = player.getVar("ScoreExpert");
var ScoreIndecisive = player.getVar("ScoreIndecisive");
var ScoreImpatient = player.getVar("ScoreImpatient");
var ScoreAggressor = player.getVar("ScoreAggressor");
var ScoreTotal = ScorePessimist + ScoreExpert + ScoreIndecisive + ScoreImpatient + ScoreAggressor;
player.SetVar("ScoreTotal", ScoreTotal);
Attempt 3) This did nothing, Total Score stayed at 0.
var player = GetPlayer();
var ScoreTotal1 = player.getVar("ScorePessimist") + player.getVar("ScoreExpert") + player.getVar("ScoreIndecisive") + player.getVar("ScoreImpatient") + player.getVar("ScoreAggressor");
player.SetVar("ScoreTotal", ScoreTotal1);
Each of my sectional scores (for example, ScorePessimist) are number variables adjusted by 10 or -10 each slide.
I'm not very familiar with JavaScript so any help would be appreciated!
Best,
Sam