title: Cannot read property 'length' of undefined on javascript
body: <p>I am facing this console error while running my code:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'length' of undefined</p>
  </blockquote>
  
  <p>Complete log</p>
  
  <pre><code>at renderUserBlocks (eval at globalEval (jquery.min.js:2), &lt;anonymous&gt;:692:47)
      at Object.success (eval at globalEval (jquery.min.js:2), &lt;anonymous&gt;:242:17)
      at i (jquery.min.js:2)
      at Object.fireWith [as resolveWith] (jquery.min.js:2)
      at z (jquery.min.js:4)
      at XMLHttpRequest.&lt;anonymous&gt; (jquery.min.js:4)
  </code></pre>
  
  <p>My Code</p>
  
  <pre><code>function renderUserBlocks(blocksResults){
          var $blocksRows = $('#blocks_rows');
          for (var i = 0; i &lt; blocksResults.length; i += 2){
              var block = parseUserBlock(blocksResults[i + 1], blocksResults[i]);
              var blockJson = JSON.stringify(block);
              var existingRow = document.getElementById('blockRow' + block.time);
              if (existingRow &amp;&amp; existingRow.getAttribute('data-json') !== blockJson){
                  $(existingRow).replaceWith(getUserBlockRowElement(block, blockJson));
                  $('[data-toggle="tooltip"]').tooltip();
              }
              else if (!existingRow){
                  var blockElement = getUserBlockRowElement(block, blockJson);
                  var inserted = false;
                  var rows = $blocksRows.children().get();
                  for (var f = 0; f &lt; rows.length; f++) {
                      var pTime = parseInt(rows[f].getAttribute('data-time'));
                      if (pTime &lt; block.time){
                          inserted = true;
                          $(rows[f]).before(blockElement);
                          break;
                      }
                  }
                  if (!inserted)
                      $blocksRows.append(blockElement);
                      $('[data-toggle="tooltip"]').tooltip();
              }
          }
      }
  </code></pre>
  
  <p>error shows on this line</p>
  
  <pre><code>for (var i = 0; i &lt; blocksResults.length; i += 2)
  </code></pre>