Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
855 B
1
Indexable
Never
function getQuestion(event) {
        event.preventDefault();

        fetch(BASE_URL)
            .then((res) => res.json())
            .then((allProducts) => {
                products = Object.values(allProducts);

                for (const { category, difficulty, question, incorrect_answers, correct_answer } of products[1]) {

                    questionn.innerHTML = question;
                    array = [...incorrect_answers];
                    array.push(correct_answer);
                    shuffleArray(array);
                    answers.A.innerHTML = array[0];
                    answers.B.innerHTML = array[1];
                    answers.C.innerHTML = array[2];
                    answers.D.innerHTML = array[3];

                }
            }).catch(err => {
            console.log(err);
        });
    }