mirror of
https://github.com/alvierahman90/capitals_quiz.git
synced 2024-11-23 17:59:55 +00:00
closes #3 show correct answer to previous question
This commit is contained in:
parent
155f41afc1
commit
1a3bb1f139
11
src/game.js
11
src/game.js
@ -10,6 +10,8 @@ const answerDHTML = document.getElementById("answer_d");
|
||||
const bodyHTML = document.getElementsByTagName("body")[0]
|
||||
const incorrectAnswersTable = document.getElementById('incorrectAnswersTable');
|
||||
const correctAnswersTable = document.getElementById('correctAnswersTable');
|
||||
const previousQuestionAnswer = document.getElementById('previousQuestionAnswer');
|
||||
const previousQuestionText = document.getElementById('previousQuestionText');
|
||||
const resultsHTML = document.getElementById("results");
|
||||
const scoreHTML = document.getElementById("score");
|
||||
const settingsHTML = document.getElementById("settings");
|
||||
@ -127,6 +129,11 @@ function updateState() {
|
||||
}
|
||||
options[Math.floor(Math.random()*4)] = countries[newQuestion].capital;
|
||||
|
||||
if (state.question) state.previousQuestion = {
|
||||
"question": state.question,
|
||||
"options": state.options,
|
||||
"answer": state.answer
|
||||
};
|
||||
state.question = newQuestion;
|
||||
state.options = options;
|
||||
state.answer = countries[newQuestion].capital;
|
||||
@ -145,6 +152,10 @@ function updateScreen(){
|
||||
answerCHTML.getElementsByClassName("text")[0].innerHTML = state.options[2];
|
||||
answerDHTML.getElementsByClassName("text")[0].innerHTML = state.options[3];
|
||||
questionHTML.innerHTML = `what is the capital of <span id="questionCountry">${state.question}</span>?`;
|
||||
if (state.previousQuestion ) {
|
||||
previousQuestionAnswer.innerHTML = state.previousQuestion.answer;
|
||||
previousQuestionText.style.display = "";
|
||||
}
|
||||
}
|
||||
|
||||
function displayEndScreen() {
|
||||
|
@ -49,6 +49,8 @@
|
||||
background: var(--good);
|
||||
}
|
||||
|
||||
#previousQuestionAnswer { background: var(--green) }
|
||||
|
||||
#game .answer {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
|
@ -36,6 +36,7 @@
|
||||
<p class="letter" id="d">d</p>
|
||||
<p class="text">answer d text</p>
|
||||
</div>
|
||||
<p id="previousQuestionText" style="display: none"> answer to previous question: <span id="previousQuestionAnswer"> </span></p>
|
||||
</div>
|
||||
<div style="display: none" id="results">
|
||||
<h1 id="resultsBreakdownHeader"> results breakdown </h1>
|
||||
|
Loading…
Reference in New Issue
Block a user