title: How to toggle on / off? (Javascript)
body: <p>I'm trying out JS without jQuery. But so far it's much harder.</p>
  
  <p>I'm trying to make a toggle on &amp; off function.</p>
  
  <p>This is the function: </p>
  
  <pre><code>function toggleDropdown(){
  
     var dropdown = document.getElementById('games-dropdown')
  
     if (dropdown.display = "none"){
      dropdown.style.display = 'block';
     } else {
      dropdown.display = "none";
     }
  }
  </code></pre>
  
  <p>I call the function here:</p>
  
  <pre><code>&lt;li class="dropdown"&gt;&lt;a onclick="toggleDropdown()"&gt;GAMES&lt;/a&gt;&lt;/li&gt;
  </code></pre>