In Captivate, you have Advanced Actions that allow (among other things) to sum the variables. To learn more about how Captivate works, you can reference their online resources. In particular, this page goes over advanced actions:
https://helpx.adobe.com/captivate/using/advanced-actions.html and should help.
So your advanced action will sum the variables, then execute the JavaScript code to send the score the leaderboard. After you save the advanced action, you can return to the slide itself and select to execute this action when slide starts.
Feel free to post more questions as they arise.