title: How to list of powers of 2 in javascript
body: <p>Programming noob here. Found this question on codewars: &quot;Complete the function that takes a non-negative integer n as input, and returns a list of all the powers of 2 with the exponent ranging from 0 to n (inclusive).&quot;</p>
  <pre><code>function powersOfTwo(n){
        var myArray = [];
        for (var i=0; i&lt;=n; i++){
          return myArray.push(2**i);
        }
        return myArray
      }
  </code></pre>
  <p>Im confused as to why this doesn't work. This is probably a noob question, but i started last week</p>