title: Array Left Rotation in Javascript will log to console but not return
body: <p>I'm working on the array left rotation on Hackerrank.  The solution that I have will console.log the array containing the correct result, but will not work using return.  Here's the detail from their site - "Print a single line of n space-separated integers denoting the final state of the array after performing d left rotations."  I've read that the issue might be with asynchronous functions running in node.js, but I'm not sure how to work around that.  </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>// sample input - 1 2 3 4 5
  // sample output - 5 1 2 3 4
  
  function rotLeft(a, d) {
    var arr = [];
  
      for (var i = 1; i &lt;= a; i++){
        arr.push(i)
      };
      for (var j = 1; j &lt;= d; j++){
       arr.shift(arr.push(j))
      }
      console.log(arr.toString()); // &lt;-- this will print the desired output.
      return arr.toString(); // &lt;-- no return from this.
  }
  
  
  rotLeft(5, 4)</code></pre>
  </div>
  </div>
  </p>