window.reload = () => {
  var userArray = JSON.parse(localStorage.getItem("key"));
}
let feedback = document.getElementById("feedback");
function checkemail(userArray, email) {
  var i;
  if (userArray == null | undefined) {
    userArray = JSON.parse(localStorage.getItem("key"));
  }
  var person = {
    name: document.getElementById("nameinput").value,
    email: document.getElementById("emailinput").value,
    passowrd: document.getElementById("passwordinput").value
  };
  let isFound = false;
  for (i = 0; i < userArray.length; i++) { //here is the error it still happen even after I added the if null part 
    if (userArray != undefined)
      var oldemail = userArray[i].email;
    let newemail = document.getElementById("emailinput").value;
    if (newemail === oldemail) {
      isFound = true;
      i = userArray.length;
      return feedback.innerHTML = "email exist please log in or register with different email";
    }
  }
  if (!isFound) {
    return storeName(person, userArray);
  }
}
function storeName(person, userArray) {
  if (userArray != undefined)
    var person = {
      name: document.getElementById("nameinput").value,
      email: document.getElementById("emailinput").value,
      passowrd: document.getElementById("passwordinput").value
    };
  userArray = JSON.parse(localStorage.getItem("key"));
  userArray.push(person);
  userArray = JSON.stringify(userArray);
  localStorage.setItem("key", userArray);
  console.log(userArray);
}I want to store an array in local storage, the first time when I run the code, of course, the array is empty and I can not use a loop for example because I can't call (array.length). so can I tell the compiler for example if the array is null or undefined just put length is zero or assign the value of the array to an empty array?
can I do something like this?
if( userArray == null | undefined) { userArray = JSON.parse(localStorage.getItem("key")); }
 
    