Я создаю игру «да / нет», и у меня есть переменная оценка, которая получает идентификатор поля, которое необходимо заполнить, счет должен обновляться каждый раз, когда человек выбирает правильный ответ.if
проверяет, включена ли фотография элемента в упомянутый массив, если это так, я должен добавить точку, если нет, я должен вернуть баллы обратно в 0.
Как я могунаписать точки, если переменная получает идентификатор?
И как я могу добавить новую точку каждый раз, когда пользователь получает правильный ответ?
Я действительно не могу получить его.спасибо.
var score = document.getElementById('score');
var foto;
var yesMeetup = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16];
var notMeetup = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26];
var notButton = document.getElementById('no');
var yesButton = document.getElementById('yes');
var decisao = document.getElementById('decisao');
document.querySelector('.btn').addEventListener('click', verify);
function verify() {
yesMeetup;
notMeetup;
if (yesButton) {
if (yesMeetup.includes(foto)) {
decisao.textContent = "You got it";
decisao.style.display = "block";
decisao.style.animation = "anim 1s";
decisao.style.animationIterationCount = "1";
parseInt(score.textContent) += "1";
} else {
decisao.textContent = "wrong";
decisao.style.animation = "anim 1s";
decisao.style.display = "block";
decisao.style.animationIterationCount = "1";
score.textContent = "0";
}
}
}
document.querySelector('#no').addEventListener('click', VerifyNo);
function VerifyNo() {
yesMeetup;
notMeetup;
if (notButton) {
if (notMeetup.includes(foto)) {
decisao.textContent = "You got it";
decisao.style.display = "block";
decisao.style.animation = "anim 1s";
decisao.style.animationIterationCount = "1";
} else {
decisao.textContent = "Wrong";
decisao.style.display = "block";
decisao.style.animation = "anim 1s";
decisao.style.animationIterationCount = "1";
}
}
}