how to hide all blocks with javasctipt
<p>I have 5 blocks, one by one they appear(4 blocks), except last (block #5), and I don't understand why the last don't want. When all blocks are shown the hide and everything starts again. I would appreciate if you explain me why it happen.</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>$(function() {
  $('div').addClass('hidden');
  var i = setInterval(showBlock, 1000);

  function showBlock() {
    var x = $("div.hidden:first").removeClass("hidden");
    if ($("div.hidden").length === 0) {
      $('div').addClass('hidden');
    }
  }
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.hidden {
  display: none;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;div&gt;1&lt;/div&gt;
&lt;div&gt;2&lt;/div&gt;
&lt;div&gt;3&lt;/div&gt;
&lt;div&gt;4&lt;/div&gt;
&lt;div&gt;5&lt;/div&gt;</code></pre>
</div>
</div>
</p>