Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve () {
- let allSections = document.querySelectorAll('section')
- let wrongAnswersCount = 0
- let wrongAnswersText = [
- 'onmouseclick',
- 'JSON.toString()',
- 'The DOM is your source HTML'
- ]
- let sections = Array.from(document.getElementsByTagName('section'))
- let answers = document.getElementsByClassName('answer-text')
- for (let j = 0; j < answers.length; j++) {
- answers[j].addEventListener('click', function () {
- if (wrongAnswersText.includes(this.innerHTML)) {
- wrongAnswersCount++
- }
- let section = sections.shift()
- section.style.display = 'none'
- let nextSection = section.nextElementSibling
- nextSection.style.display = 'block'
- console.log(section)
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement