title: how to rewrite jQuery ToggleClass and if/else code into vanilla JS?
body: <p>I have a small jQuery code for handling some toggle class and HTML5 local-storage and I would like to convert it into a modern vanilla JS code.
  I have to say I have no clue where to start.</p>
  
  <p>Can someone by any chance show me the correct approach for a modern JS code for this?  I would really appreciate it. </p>
  
  <p>example demo:
  <a href="http://jsbin.com/wimojapowo/1/edit?html,css,js,output" rel="nofollow noreferrer">http://jsbin.com/wimojapowo/1/edit?html,css,js,output</a></p>
  
  <pre class="lang-js prettyprint-override"><code>$('#container').toggleClass(localStorage.toggled);
  
  $('.bar-toggle').on('click', function() {
    //localstorage values are always strings (no booleans)  
    if (localStorage.toggled != "with_toggle") {
      $('#container').toggleClass("with_toggle", true);
      localStorage.toggled = "with_toggle";
    } else {
      $('#container').toggleClass("with_toggle", false);
      localStorage.toggled = "";
    }
  });
  </code></pre>