title: Google Firebase, Alert on register and login errors
body: <p>Currently working on a login and registration system using google firebase for authentication. Login and register account functions are working. I have added a window alert if the user has been properly logged in and logged out. I am struggling with adding a window alert if the user is trying to register with an existing email or if the user enters an invalid email or password when trying to login. Here are my functions for registering and logging in:
  What other code should/must I add to it in order to have the alert?</p>
  
  <pre><code>// signup
  const signupForm = document.querySelector("#signup-form");
  signupForm.addEventListener("submit", e =&gt; {
    e.preventDefault();
  
    // get user info
    const email = signupForm["signup-email"].value;
    const password = signupForm["signup-password"].value;
  
    // sign up the user
    auth.createUserWithEmailAndPassword(email, password).then(cred =&gt; {
      // close the signup modal &amp; reset form
      const modal = document.querySelector("#modal-signup");
      M.Modal.getInstance(modal).close();
      signupForm.reset();
    });
  });
  </code></pre>
  
  <pre><code>// login
  const loginForm = document.querySelector("#login-form");
  loginForm.addEventListener("submit", e =&gt; {
    e.preventDefault();
  
    // get user info
    const email = loginForm["login-email"].value;
    const password = loginForm["login-password"].value;
  
    // log the user in
    auth.signInWithEmailAndPassword(email, password).then(cred =&gt; {
      // close the signup modal &amp; reset form
      const modal = document.querySelector("#modal-login");
      M.Modal.getInstance(modal).close();
      loginForm.reset();
    });
  });
  </code></pre>