title: Why does this code show `undefined` when pasted into the browser console?
body: <p>I am having issues trying to run a simple function with an array, it runs undefined, but when I console log it I get th right result?</p>
  
  <p>Please can anyone help?</p>
  
  <pre><code>var test = (function (newThing){
  
    newThing = [1,2,3,4,5,6];
  
    var  myarray = newThing.map(n=&gt;n*n)
      .reduce((a,b)=&gt; {return a+b});
  
    return myarray;
  })();
  </code></pre>