#why is my element(item) a null?

5 messages · Page 1 of 1 (latest)

vapid basin
#
const phone = document.querySelector('#phone')
const password = document.querySelector('#password')
const confirmPassword = document.querySelector('#confirm-password')
const errorMessage = document.querySelector('.errorMessage')

const input = [email, phone, password, confirmPassword]

input.forEach((item) => {
    item.addEventListener("focusin", () => {
      errorMessage.textContent = "";
      item.classList.remove("error");
      if (item == password || item == confirmPassword) {
        password.classList.remove("error");
        confirmPassword.classList.remove("error");
      }
    });
});```

I'm trying to create a validation form in JS but i can't figure out why "item" for the eventlistener has a typeerror of null.
sweet urchin
#

You have a const input then call item

sweet urchin
#

Oh wait I read it wrong

#

Console log input and see what it says