title: Checking variable status from another JavaScript module using export default
body: <p>I have two Javascript modules, one for my navigation, and one for route changes. </p>
  
  <p>Inside of nav.js is simple if to check if the menu can be opened </p>
  
  <pre><code>const initNav = () =&gt; {
    const openMenu = () =&gt; {
      if (!menuIsOpen &amp;&amp; isMobile) {
        navItems.classList.add("is-menu-open");
        menuIsOpen = true;
      } else {
        navItems.classList.remove("is-menu-open");
        menuIsOpen = false;
     }
   }
  }
  
  initNav();
  
  export default initNav;
  </code></pre>
  
  <p>Then, at the top of the other module I  import </p>
  
  <pre><code>import initNav from './nav.js';
  </code></pre>
  
  <p>The question is, inside of my other module <code>route.js</code>, I need to be able to check if the menu is opened, and, if it is then close it, so I was going to use: </p>
  
  <pre><code> beforeLeave: function (data) {
      if (menuIsOpen) {
        navItems.classList.remove("is-menu-open");
        menuIsOpen = false;
      }
   }
  </code></pre>
  
  <p>The console, however, says <code>menuIsOpen</code> is not defined. </p>
  
  <p>I can't then this way check to see the status of this variable. </p>
  
  <p>Am I able to do this another way, rather than combining the two modules into one very large js module? </p>