09. JavaScript Quizz от DOM Manipulation and Events - Exercise
Здравейте, получавам 50/100, някой може ли да ми помогне ?
Благодаря :)
задача: https://judge.softuni.org/Contests/Practice/Index/2763#8
код:
function solve() {
let points = 0;
let answers = Array.from(document.querySelectorAll('.answer-text'))
let[one, two, three, four, five, six] = answers
let currSection = 0;
let question = document.getElementsByTagName('section');
Array.from(document.querySelectorAll('.quiz-answer'))
.map((x) => x.addEventListener('click', (answer) => {
if (answers.includes(two, four, six)) {
points++;
};
question[currSection].style.display = 'none';
currSection++;
currSection !== 3
? question[currSection].style.display = 'block'
: printResult(points);
}));
function printResult(points) {
document.querySelector("#results").style.display = 'block';
let text = '';
points === 3
? text = 'You are recognized as top JavaScript fan!'
: text = `You have ${points} right answers`;
document.querySelector("#results > li > h1").textContent = text;
}
}
Благодаря !