Discord Trivia Command

Im making a trivia command for my bot that can show a question and 4 possible answers. However a possiable answer sometimes hosws up more then once and the real answer doesnt show up.

This is my code:

const response = await fetch(
    const data = await response.json();

    const questionData = data.results[0];
    const correctQuestion = questionData.correct_answer;
    const incorrectAnswers = questionData.incorrect_answers;
    const questions = [

    const question1 = questions[~~(Math.random() * questions.length)];
    const question2 = questions[~~(Math.random() * questions.length)];
    const question3 = questions[~~(Math.random() * questions.length)];
    const question4 = questions[~~(Math.random() * questions.length)];
    if (question1 == correctQuestion) var correctNumber = 1;
    if (question2 == correctQuestion) var correctNumber = 2;
    if (question3 == correctQuestion) var correctNumber = 3;
    if (question4 == correctQuestion) var correctNumber = 4;

Thanks in advance!

why not make a function? than creating such messy a code? You can easily make this code much cleaner and simple…

Can you show me how you would do this? I’m not the best with JavaScript