title: Javascript - Undefined array value after string .split
body: <p>I wanted to check if a string is palindrome, but I have a problem in reversing a string. I know there's a lot of Questions about palindrome in Javascript, but i want to find it on my way and I still can't find the solution on those Questions.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>function reverse(string){
    var str = string;
    var split = str.split("");
    var newStr= "";
  
    for(var i=split.length; i&gt;=0; i--){
       newStr += split[i];
    }
  
    console.log(newStr); 
  }
  
  var str= 'blue';
  
  reverse(str);
  </code></pre>
  
  <p><strong>Results</strong></p>
  
  <pre><code>"undefinedeulb"
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>As we can see, the results was an undefined value at the start of the string.
  I tested this code with PHP script, and It works fine. How could this be a problem with Javascript? and How to get rid of it?</p>