title: TypeError: Cannot read property 'search' of undefined
body: <p>hi i'm trying make a simple search using arrays, but i get this error:</p>
  
  <pre><code> TypeError: Cannot read property 'search' of undefined
  </code></pre>
  
  <p>this is my code:</p>
  
  <pre><code>var debug  = [];
  var search = function (data, wordSearch) {
    "use strict";
  
    var
      wordList = [], //set a word lists to send a result.
      i = 0,
      word,
      cutedWord;
  
    debug.push(data);
    while (i &lt;= data.length) {
      word = data[i];
      if (word.search(wordSearch) !== -1) {
        wordList.push(data[i]);
      }
      i++;
    }
    return (wordList);
  };
  </code></pre>