-2

[i am trying to make a quiz website but when ever i try to run my code it gave me this error: q1.js:1 Uncaught TypeError: Cannot read properties of null (reading 'addEventListner') i don't undderstand what i need to do][1] here is my html code:

<div id="controls">
                <button id="start-btn" class="start-btn btn">start</button>
                <button id="next-btn" class="next-btn btn hide">next</button>
            </div>

my javascript code:

const startButton = document.getElementById('startGame')


let shuffleQuestion, currentQuestionIndex;
if (startButton) {
document.getElementById("start-btn").addEventListner('click',startGame);
}
function startGame()
{
    console.log('Started');
    startButton.classList.add('hide');
    shuffleQuestion = question.sort(() => Math.random()- .5);
    currentQuestionIndex=0;
    questionContainerElement.classList.remove('hide');
    setNextQuestion();

}

0 Answers0