title: closing modal on window vanilla js
body: <p>I've been trying to figure out how to close the modal I made by a window click but have no success. My modal is activated by adding a class and removing the 'show-modal' class. So I created the window event listener and seems like whenever I press the &quot;a&quot; tag in my HTML, it also considers that click as part of the window so the modal won't even open.</p>
  <p>However, once I remove the window event listener, the modal is working fine; but the modal does not close unless I hit the &quot;closeModal&quot; button.</p>
  <p>Is there something I am doing wrong or improve on? I tried googling around but their idea is different than mine.</p>
  <p>I know I can do this using React &amp; Boostrap but I am also trying to learn the vanilla JS way so I want to do this right!</p>
  <pre><code>const contact = document.querySelector('.contact');
  const modal = document.querySelector('.modal');
  const closeModal = document.querySelector('.closeBtn');
  
  contact.addEventListener('click', showModal);
  closeModal.addEventListener('click', modalClose);
  window.addEventListener('click', modalClose);
  
  function showModal(){
      modal.classList.add('show-modal');
      console.log('clicked')
  }
  
  function modalClose(){
      modal.classList.remove('show-modal');
      console.log('closed')
  }
  
  
  </code></pre>