make several correct answer
This commit is contained in:
parent
b8aa4b66af
commit
498ab5502a
6
TODO.md
6
TODO.md
@ -1,11 +1,9 @@
|
||||
- loading all quest images with loading
|
||||
- splash (loading) screen
|
||||
- several correct answer
|
||||
- change quest animation
|
||||
- button hover animation
|
||||
- make docs/
|
||||
|
||||
- google: if webpack mode production remove DEBUG code
|
||||
|
||||
## done
|
||||
- loading all quest images with loading [b8aa4b6]
|
||||
- splash (loading) screen [b8aa4b6]
|
||||
- add quest progress [aac38ec]
|
||||
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"questions": [
|
||||
{
|
||||
"question": "Выбери вариант МОСТ",
|
||||
"question": "Выбери вариант МОСТ или РЕКА",
|
||||
"image": "image_land.jpg",
|
||||
"answer": [ "Мост", "Рудник", "Река", "Солнце" ],
|
||||
"rightAnswer": "мост"
|
||||
"rightAnswer": [ "мОст", "РЕКА" ]
|
||||
},
|
||||
{
|
||||
"question": "Что горит?",
|
||||
|
14
js/game.js
14
js/game.js
@ -19,12 +19,26 @@ export function imagePreloader(images, callback) {
|
||||
}
|
||||
|
||||
export function checkAnswer(quest, answer) {
|
||||
if (Array.isArray(quest.rightAnswer)) {
|
||||
let lowerCaseArray = [];
|
||||
|
||||
quest.rightAnswer.forEach(item => lowerCaseArray.push(item.toLowerCase()))
|
||||
|
||||
if (lowerCaseArray.includes(answer.toLowerCase())) {
|
||||
quest.status = true;
|
||||
}
|
||||
else {
|
||||
quest.status = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (quest.rightAnswer.toLowerCase() == answer.toLowerCase()) {
|
||||
quest.status = true;
|
||||
}
|
||||
else
|
||||
quest.status = false;
|
||||
}
|
||||
}
|
||||
|
||||
export function shuffle(array) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
|
Loading…
Reference in New Issue
Block a user