The addEventListener is encased inside the function, so it’ll only be added once getInfo() is called, a Catch22. You need to put the addEventListener and the applyNow variable outside of the function.

function getInfo() {
  let name = prompt("What is your first name?");
  let age = prompt("What is your age?");
let applyNow = document.querySelector("button");
applyNow.addEventListener("click", getInfo);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top