I'm designing a quiz app for fun. The quiz will show one question, and it's four options to answer. I'm using vanilla JS to update the DOM, and need to add an eventListener for each answer that is rendered. For some reason, the eventListener is firing as soon as the DOM is rendered. Any ideas as to why?
//add each answer to the answerContainer
answerContainer.innerHTML = '';
for (let i = 0; i < allAnswersFlattened.length; i++) {
let individualAnswer = document.createElement('div');
individualAnswer.className = 'answer';
let answerText = document.createTextNode(allAnswersFlattened[i]);
individualAnswer.appendChild(answerText);
individualAnswer.addEventListener("click", checkForAnswer(i, allAnswersFlattened));
answerContainer.appendChild(individualAnswer);
}