title: JavaScript 99Bottles - Infinite Loop
body: <p>(I already know that this isn't the most elegant solution to the 99 bottles code challenge, but I'd really like to know how not to repeat this mistake in the future.)</p>
  <p>When this runs in the console it repeats the <code>(count === 0)</code> condition and repeats nothing but the <code>&quot;0 bottles of beer&quot;</code> console log until it crashes.</p>
  <p>I've experimented with using a 'break' statement after the count decrements to 0, but haven't had any success.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let count = 99;
  
  function bottlesOfBeer() {
      while (count &gt;= 0) {
          if (count &gt; 0) {
              console.log(count + " bottles of beer on the wall, " + count + " bottles of beer,");
              count--;
              console.log(" take one down, pass it around, " + count + " bottles of beer on the wall.");  
          };
  
          if (count === 0) {
              console.log(count + " bottles of beer on the wall, " + count + " bottles of beer. Go to the store, buy some more, 99 bottles of beer on the wall.");
          } //*this is where I tried the break statement*
      }
  };
  
  bottlesOfBeer();</code></pre>
  </div>
  </div>
  </p>