Skip to content

Instantly share code, notes, and snippets.

@Innei
Created June 24, 2020 05:17
Show Gist options
  • Save Innei/c7237e0a2c51380ecb38044404c17ebd to your computer and use it in GitHub Desktop.
Save Innei/c7237e0a2c51380ecb38044404c17ebd to your computer and use it in GitHub Desktop.
ketangpai
log = console.log
list = document.querySelectorAll('.test-t > li')
questions = [];
[...list].map(ch => {
log(ch)
const title = ch.querySelector('.title').textContent.trim();
const answerBox = ch.querySelector('.answer-box')
let answers = []
if (answerBox) {
answers = [...answerBox.querySelectorAll('li')].map(l => {
return l.textContent.trim()
})
}
questions.push({
title,
answers
})
})
console.log(questions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment