Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. function solve() {
  2. let rightAnswers = 0;
  3. let firstRightButton = document.querySelector("#quizzie > section:nth-child(2) > ul > li.quiz-answer.low-value > div > p");
  4. let firstWrongButton = document.querySelector("#quizzie > section:nth-child(2) > ul > li.quiz-answer.high-value > div > p");
  5. function firstAnswer(){
  6. rightAnswers++;
  7.  
  8. firstAnswerDisapear();
  9. };
  10. function firstAnswerDisapear(){
  11. document.querySelector("#quizzie > section:nth-child(2) > ul").style.display = "none";
  12. document.querySelector("#quizzie > section:nth-child(3)").style.display= "block";
  13. }
  14. firstRightButton.addEventListener("click", firstAnswer);
  15. firstWrongButton.addEventListener("click", firstAnswerDisapear);
  16.  
  17.  
  18.  
  19. let secondWrongButton = document.querySelector("#quizzie > section:nth-child(3) > ul > li.quiz-answer.low-value > div > p");
  20. let secondRightButton = document.querySelector("#quizzie > section:nth-child(3) > ul > li.quiz-answer.high-value > div > p");
  21. function secondAnswer(){
  22. rightAnswers++;
  23.  
  24. secondAnswerDisapear();
  25. }
  26. function secondAnswerDisapear(){
  27. document.querySelector("#quizzie > section:nth-child(3)").style.display= "none";
  28. document.querySelector("#quizzie > section:nth-child(4)").style.display= "block";
  29. }
  30. secondRightButton.addEventListener("click", secondAnswer);
  31. secondWrongButton.addEventListener("click", secondAnswerDisapear);
  32.  
  33.  
  34.  
  35. let thirdRightButton = document.querySelector("#quizzie > section:nth-child(4) > ul > li.quiz-answer.low-value > div > p");
  36. let thirdWrongButton = document.querySelector("#quizzie > section:nth-child(4) > ul > li.quiz-answer.high-value > div > p");
  37. let result = document.createElement('div');
  38. function thirdAnswer(){
  39. rightAnswers++;
  40. thirdAnswerDisapear();
  41. }
  42. let topJS = `You are recognized as top JavaScript fan!`;
  43. function thirdAnswerDisapear(){
  44. document.querySelector("#quizzie > section:nth-child(4)").style.display= 'none';
  45. if (rightAnswers === 3) {
  46. document.querySelector("#results > li > h1").innerHTML= topJS;
  47. }else{
  48. document.querySelector("#results > li > h1").innerHTML= `You have ${rightAnswers} right answers.`;
  49. }
  50. document.querySelector("#results").style.display= "block";
  51. }
  52.  
  53. thirdRightButton.addEventListener("click", thirdAnswer);
  54. thirdWrongButton.addEventListener("click", thirdAnswerDisapear);
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement