Skip to content
Justice Tech School

Project: A Quiz Game

Keep questions in an array of objects, track the score and index in variables, and write small functions for ask, check and finish.

Example
const questions = [{ q: "2 + 2", a: "4" }, { q: "Capital of Nigeria", a: "Abuja" }];
let score = 0;
for (const { q, a } of questions) {
  const given = a;
  if (given === a) score++;
}
console.log(`${score}/${questions.length}`);

Exercise

Count correct answers.

score

Quiz Test

Where should questions live?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.