Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let rightAnswers = 0;
- let firstRightButton = document.querySelector("#quizzie > section:nth-child(2) > ul > li.quiz-answer.low-value > div > p");
- let firstWrongButton = document.querySelector("#quizzie > section:nth-child(2) > ul > li.quiz-answer.high-value > div > p");
- function firstAnswer(){
- rightAnswers++;
- firstAnswerDisapear();
- };
- function firstAnswerDisapear(){
- document.querySelector("#quizzie > section:nth-child(2) > ul").style.display = "none";
- document.querySelector("#quizzie > section:nth-child(3)").style.display= "block";
- }
- firstRightButton.addEventListener("click", firstAnswer);
- firstWrongButton.addEventListener("click", firstAnswerDisapear);
- let secondWrongButton = document.querySelector("#quizzie > section:nth-child(3) > ul > li.quiz-answer.low-value > div > p");
- let secondRightButton = document.querySelector("#quizzie > section:nth-child(3) > ul > li.quiz-answer.high-value > div > p");
- function secondAnswer(){
- rightAnswers++;
- secondAnswerDisapear();
- }
- function secondAnswerDisapear(){
- document.querySelector("#quizzie > section:nth-child(3)").style.display= "none";
- document.querySelector("#quizzie > section:nth-child(4)").style.display= "block";
- }
- secondRightButton.addEventListener("click", secondAnswer);
- secondWrongButton.addEventListener("click", secondAnswerDisapear);
- let thirdRightButton = document.querySelector("#quizzie > section:nth-child(4) > ul > li.quiz-answer.low-value > div > p");
- let thirdWrongButton = document.querySelector("#quizzie > section:nth-child(4) > ul > li.quiz-answer.high-value > div > p");
- let result = document.createElement('div');
- function thirdAnswer(){
- rightAnswers++;
- thirdAnswerDisapear();
- }
- let topJS = `You are recognized as top JavaScript fan!`;
- function thirdAnswerDisapear(){
- document.querySelector("#quizzie > section:nth-child(4)").style.display= 'none';
- if (rightAnswers === 3) {
- document.querySelector("#results > li > h1").innerHTML= topJS;
- }else{
- document.querySelector("#results > li > h1").innerHTML= `You have ${rightAnswers} right answers.`;
- }
- document.querySelector("#results").style.display= "block";
- }
- thirdRightButton.addEventListener("click", thirdAnswer);
- thirdWrongButton.addEventListener("click", thirdAnswerDisapear);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement