Want to get the content from the quizzes without manually copy pasting?

I wanted to get the questions from the quizzes in the Web Developer course so I could practice later, but found it a bore to manually copy and paste everything into a separate file, so I wrote this bit of JavaScript to do it for me:

getQuizContent = () => {
    const questionContainerNodeList = document.querySelectorAll('.margin-bottom-l ');
    return Array.from(questionContainerNodeList).map(containerNode => {
        return Array.from(containerNode.getElementsByClassName('quiz-question__text')).map(questionNode => {
            const question = questionNode.innerText;
            const answerNodes = container.getElementsByClassName('quiz-answer__answer');
            answers = Array.from(answerNodes).map(node => node.innerText);
            return {
                question,
                answers
            }
        })
    })
    .flat()
    .reduce(formatQuestionText, '')
}

printQuizContent()

How to use:
1. Open console (F12)

2. Paste the code


If you're reading this and have the same problem, I hope it's helpful. If it doesn't work, feel free to change it.

Hello!

Well done.

Thanks