Custom JavaScript code

Hello,

I’m trying to declare a variable via ActivePresenter->Project->Properties->Event:
var score = 0;
Within some questions and their onCorrect event I increment the score by one. Now on the last slide I’m trying to access my variable but without success. I tried using alert(score); , console.log(score); but I can’t get it outputted. I can output the text object where I want to show the score later by passing it into alert after retrieving via: prez.object.
Any ideas? It can’t be so hard to get a variable declared and access it again.

Hi Kevin,

Score is already supported, you don’t need to do it manually using JavaScript.
You can take a look at this tutorial: https://atomisystems.com/tutorials/ap7/question-score-report-activepresenter-7/

About your code, a variable defined in an action is local to that action only.
If you want to access it from other actions, please define it as a property of a global object. For example:
prez.myScore = 0 in an action, alert(prez.myScore) in another action.

Regards