function toggleMenu() {

    /**
     * Alternate menuIsOpen between true/false on each click.
     * ---
     * NOTE: This needs to happen before checking if the menu is open so that
     *       the localStorage items will be added in the right sequence.
     */  
    menuIsOpen = !menuIsOpen;

    // Check if the push menu has the "open-on-load" class
    if ($pushSelectors.hasClass("open-on-load")) {

      // If it does, remove the class so that we can add the "open" class later
      $pushSelectors.removeClass("open-on-load");

      // Let's send a message to the console to let us know what happened
      console.log("The 'open-on-load' class has been removed.");

    }

    // Check if the push menu should be open
    if (menuIsOpen) {

      /**
       * If the push menu should be open, we'll add a class to animate it into
       * the "open" position.
       */
      $pushSelectors.addClass("open");

      /**
       * We will also add the "opened" state to a localStorage item. This is the
       * property that tells the browser that the menu should be open.
       * ---
       * NOTE: localStorage will only store strings, we can use "opened" and
       *       "closed" as values to determine which state should be set.
       */
      localStorage.setItem("pushSelectors", "opened");
      //                          ^             ^
      //                         key          value

      // And send a message to the console to let us know...
      console.log("The 'opened' storage item has been set.");

    } else {

      /**
       * If the push menu should not be open, we'll remove the "open" class which
       * will animate it back into the "closed" position.
       */
      $pushSelectors.removeClass("open");

      // Now set the storage item to "closed"...
      localStorage.setItem("pushSelectors", "closed");

      // And send a message to the console to let us know...
      console.log("The 'closed' storage item has been set.");

    }

  }
// Set up a function to be used by the click event on $toggleButton
Set up a function to be used by the click event on $toggleButton
Set up a function to be used by the click event on $toggleButton
function toggleMenu() {
    menuIsOpen = !menuIsOpen;
    if ($pushSelectors.hasClass("open-on-load")) {
      $pushSelectors.removeClass("open-on-load");
      console.log("The 'open-on-load' class has been removed.");
    }
    if (menuIsOpen) {
      $pushSelectors.addClass("open");
      localStorage.setItem("pushSelectors", "opened");
      console.log("The 'opened' storage item has been set.");
    } else {
      $pushSelectors.removeClass("open");
      localStorage.setItem("pushSelectors", "closed");
      console.log("The 'closed' storage item has been set.");
    }
  }
function toggleMenu ( ) { menuIsOpen = ! menuIsOpen ; if ( $pushSelectors . hasClass ( "open-on-load" ) ) { $pushSelectors . removeClass ( "open-on-load" ) ; console . log ( "The 'open-on-load' class has been removed." ) ; } if ( menuIsOpen ) { $pushSelectors . addClass ( "open" ) ; localStorage . setItem ( "pushSelectors" , "opened" ) ; console . log ( "The 'opened' storage item has been set." ) ; } else { $pushSelectors . removeClass ( "open" ) ; localStorage . setItem ( "pushSelectors" , "closed" ) ; console . log ( "The 'closed' storage item has been set." ) ; } }
Set up a function to be used by the click event on $toggleButton
Set up a function to be used by the click event on $toggleButton
/**
     * Alternate menuIsOpen between true/false on each click.
     * ---
     * NOTE: This needs to happen before checking if the menu is open so that
     *       the localStorage items will be added in the right sequence.
     */ // Check if the push menu has the "open-on-load" class // If it does, remove the class so that we can add the "open" class later // Let's send a message to the console to let us know what happened // Check if the push menu should be open /**
       * If the push menu should be open, we'll add a class to animate it into
       * the "open" position.
       */ /**
       * We will also add the "opened" state to a localStorage item. This is the
       * property that tells the browser that the menu should be open.
       * ---
       * NOTE: localStorage will only store strings, we can use "opened" and
       *       "closed" as values to determine which state should be set.
       */ //                          ^             ^ //                         key          value // And send a message to the console to let us know... /**
       * If the push menu should not be open, we'll remove the "open" class which
       * will animate it back into the "closed" position.
       */ // Now set the storage item to "closed"... // And send a message to the console to let us know...