mirror of
https://github.com/alvierahman90/capitals_quiz.git
synced 2024-11-23 17:59:55 +00:00
fix bug where switchins between modes doesn't update answer list
This commit is contained in:
parent
3b5a172ea8
commit
a60e70968b
4
game.js
4
game.js
@ -42,7 +42,7 @@ const getQuestionHTML = (state) => {
|
|||||||
return `what is the capital of <span id="questionCountry">${state.question}</span>?`
|
return `what is the capital of <span id="questionCountry">${state.question}</span>?`
|
||||||
}
|
}
|
||||||
|
|
||||||
const answer_list = Object.values(getMasterQuestionList()).map(item => item.answer);
|
const answer_list = () => Object.values(getMasterQuestionList()).map(item => item.answer);
|
||||||
|
|
||||||
|
|
||||||
const regionList = [...new Set(Object.values(getMasterQuestionList()).map(item => item.region))]
|
const regionList = [...new Set(Object.values(getMasterQuestionList()).map(item => item.region))]
|
||||||
@ -146,7 +146,7 @@ function updateState() {
|
|||||||
var newQuestion = questionList.pop();
|
var newQuestion = questionList.pop();
|
||||||
var options = []
|
var options = []
|
||||||
while (options.length < 4) {
|
while (options.length < 4) {
|
||||||
var c = answer_list[Math.floor(Math.random()*answer_list.length)];
|
var c = answer_list()[Math.floor(Math.random()*answer_list().length)];
|
||||||
if (c !== getMasterQuestionList()[newQuestion].answer && !options.includes(c)){
|
if (c !== getMasterQuestionList()[newQuestion].answer && !options.includes(c)){
|
||||||
options.push(c);
|
options.push(c);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user