title: Reversing an array - understanding the solution
body: <p>I've been working through Eloquent JS and couldn't figure out the "reversing an array" problem. </p>
  
  <p>There are parameters to the question such as not being able to use arr.reverse. Anyways, the solution to reversing the same array, in place, threw me off guard and I am looking for someone to help break it down.</p>
  
  <pre><code>function reverseArrayInPlace(arr) {
    var length = (Math.floor(arr.length))/2;
  
    for (var i = 0; i &lt; length; i++) {
      var old = arr[i];
      arr[i] = arr[arr.length - 1 - i];
      arr[arr.length - 1 - i] = old;
   }
    return arr;
  }
  </code></pre>
  
  <p>I feel like this would be the breakdown:</p>
  
  <pre><code>function reverseArrayInPlace(arr) {
    var length = (Math.floor(arr.length))/2;
  
    for (var i = 0; i &lt; length; i++) {
      var old = arr[i];                  // var old now equals 1
      arr[i] = arr[arr.length - 1 - i]; //  5 - 1 - 0 = 4. Arr[i] = 4
      arr[arr.length - 1 - i] = old;   // 4th position of arr = 1
                                      // new arr is 4,2,3,1,5 ?
   }
    return arr; 
  }
  
  
   var arrayValue = [1, 2, 3, 4, 5];
  reverseArrayInPlace(arrayValue);
  console.log(arrayValue);
  </code></pre>
  
  <p>The solution works, so obviously my logic is off. Where am I going wrong?    </p>