title: I have a problem with the dark mode button on my webpage. Whatever i do, it always bugs as if it was a infinity loop
body: <pre><code>  var paragraphs = document.getElementsByTagName("p");
      var i = paragraphs.length;
      function toggleDarkMode(){
        while(i&gt; 0){
          paragraphs[i-1].classList.toggle("dark-mode-p");
  
          i-1;
        }
      }
  </code></pre>
  
  <p>I tried to put the variables inside the function, didn't help either :(</p>
  
  <p>Then I decided to use the for loop:</p>
  
  <pre><code>function toggleDarkMode(){
    var paragraphs = document.getElementsByTagName("p");
    for(var i = paragraphs.length; i &gt;= 0; i--){
  
      paragraphs[i-1]classList.toggle("dark-mode-p");
  
    }
  }
  </code></pre>
  
  <p>Ps. sorry for my English, I know it sucks XD</p>