title: show/hide if in pure javascript
body: <p>I wrote a script that hide/show me sidenav. My problem is that I would like to have all in one function. First, whether that examined the sidenav is hidden or not. If hidden, by clicking showed sidenav and if sidenav visible, click to hide sidenav.
  My code:</p>
  
  <pre><code>function showSideNav () {
      var sideNav = document.getElementById("slide-out");
  
      sideNav.style.cssText = "transform: translateX(0); -webkit-transition: 0.5s;";
  }
  
  function closeSideNav () {
      var sideNav = document.getElementById("slide-out");
  
      sideNav.style.cssText = "transform: translateX(-100%); -webkit-transition: 0.5s;";
  }
  </code></pre>