title: Making my button turn my page black when you click on it with JavaScript
body: <p>I have been trying to make a toggle button that when pressed, would turn the page black for my own eyes sake, but have been unable to do so. Here is how it looks when i try: <a href="https://gyazo.com/5cd21085350b603f9289bb5f64b2361e" rel="nofollow noreferrer">https://gyazo.com/5cd21085350b603f9289bb5f64b2361e</a> I'am not good with JavaScript so its not that complicated. I have my button that looks like this:</p>
  
  <pre><code>        &lt;label class="switch" onclick="pagecolor();"&gt;
            &lt;input type="checkbox"&gt;
            &lt;span class="slider round"&gt;&lt;/span&gt;
          &lt;/label&gt;
  </code></pre>
  
  <p>And here is my JavaScript:</p>
  
  <pre><code>function pagecolor(){
      if(document.body.style.backgroundColor = "white") {
          document.body.style.backgroundColor = "black";
      } else {
          document.body.style.backgroundColor = "white";
      }
  }
  </code></pre>
  
  <p>Hope you can help :)</p>