Score and the Next Question

One question isn't much of a quiz. Now the player goes through all of them and collects points:

  • Show the score in a paragraph with the class score, Score: 0 at the start. Each right answer adds a point.
  • Once the player has answered, show a button Next question. It shows the next question with its answers, which can be clicked again, and without feedback.
  • Above the question, show where the player is, Question 1 of 4, in a paragraph with the class progress.

The last question has no next one, so leave its Next question button out for now. The next exercise adds the end of the game.

A tip: which question is shown is a number in state: its index in questions, starting at 0, so the question is questions[index]. And the score can go up in the answer's handler, so it's right as soon as the feedback shows.

Instructions

Show the score, and add a point for each right answer.

After an answer, show the button Next question, which moves on to the next question. Leave it out on the last question.

Show which question the player is on.

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

Back

2/3

Next