Write your own questions and rules.
Answer enough questions correctly to reach the goal before you run out of lives.
You write these functions. The game calls them when something happens.
onCorrect()
Runs after a right answer.
function onCorrect() {
score = score + 1;
}onWrong()
Runs after a wrong answer.
function onWrong() {
lives = lives - 1;
}Variables at the top of your code are the game's settings. Change a value, press Play, and see what happens.
Each step shows code you can add to the end of your game's code. A function or variable written later replaces the earlier one, so you never have to delete anything.
Each question is an object with three parts: q (the question), options (2 to 4 choices) and answer (the number of the right choice, counting from 0).
let questions = [
{ q: "What is 2 + 2?", options: ["3", "4", "5"], answer: 1 },
{ q: "Which animal says moo?", options: ["Cow", "Duck"], answer: 0 },
];Make each right answer worth 4 points and the goal 20. Rules are just numbers you choose.
let goal = 20;
function onCorrect() {
score = score + 4;
}Lives are not the only way to be punished. Here a wrong answer takes 3 points off instead, and Math.max stops the score going below 0.
function onWrong() {
score = Math.max(0, score - 3);
}// โ My Quiz Show
let goal = 2; // correct answers needed to win
let lives = 3;
// Each question has: q (the question), options (2 to 4 choices),
// and answer (which choice is right, counting from 0).
let questions = [
{ q: "What is 2 + 2?", options: ["3", "4", "5"], answer: 1 },
{ q: "Which animal says moo?", options: ["Cow", "Duck"], answer: 0 },
{ q: "How many legs does a spider have?", options: ["6", "8", "10"], answer: 1 },
];
function onCorrect() {
score = score + 1;
}
function onWrong() {
lives = lives - 1;
}๐ ๏ธ Make your own Quiz Show game
Game Studio and the full lessons are part of Premium.