title: ecmascript-6 function to reverse values in an array
body: <p>Why doesn't this two codes do the same thing ?</p>
  
  <p>Can someone explain to me where is the trick ?</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 randomize(arr){
  
      for(var i = 0; i &lt; arr.length; i++){
          const random = Math.floor(Math.random()*arr.length);
          let temp = arr[i];   
          let newR = arr[random];
          [temp, newR] = [newR, temp];
          
      }
      return arr;
  }
  
  console.log(randomize([1,2,3,4,5]));</code></pre>
  </div>
  </div>
  </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 randomize(arr){
  
      for(var i = 0; i &lt; arr.length; i++){
          const random = Math.floor(Math.random()*arr.length);
  
          [arr[i], arr[random]] = [arr[random], arr[i]];
          
      }
      return arr;
  }
  
  console.log(randomize([1,2,3,4,5]));</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am most grateful for your read !</p>