I'm trying to implement a score to my quiz.
Currently how it works is when the user clicks the correct answer (which is a button), it displays to the frame where it says the answer is correct and displays the score.
if the user gets the answer wrong (again a button), it will go to the frame where it says the answer is wrong and the score will stay the same.
My code is as follows for the quiz buttons:
first correct answer:
//implementation of score
var score;
score = 0;
//adding points to score
score ++;
//setting the txt text field to score
scorecounter.text = score.toString();
//not embedding the font to display the score
scorecounter.embedFonts = false;
every corresponding correct answer:
//adding to score
score ++;
//setting the txt text field to score
scorecounter.text = score.toString();
scorecounter.embedFonts = false;
every corresponding incorrect answer:
//adding to score
score --;
//setting the txt text field to score
scorecounter.text = score.toString();
scorecounter.embedFonts = false;
I've got static text that says score, and dynamic text next to it that's blank and called scorecounter, where I'd like the score to go up by one.
What's happening now is that when the user answers the first answer incorrect (or enough incorrect) to display "NaN".
The quiz has five questions so I'd like the number variables to go down if the user gets the question wrong but only let it go down to zero, and to a maximum of five as the highest score possible (if user gets all correct).
How can I do that? Cheers!