I have the flowing code:
QuestionID = 0;
var score1 = 0;
var score2 = 0;
function clickanswer(answer) {
QuestionID++;
if (QuestionID <= 50) {
if (QuestionID == 2 || QuestionID == 5) {
score1 = score1 + answer;}
if (QuestionID == 4 || QuestionID == 7) {
score2 = score2 + answer; }
}
}
function useScores(){
var data1 = score1;
var data2 = score2; }
The clickanswer(answer) is an onlick event function from a button.
How can I use score1 and score2 variables from clickanswer(answer) function in useScores() function?
Thanks.
QuestionIDbefore deciding how the scores should compute? Looks buggy to me.