I found this task on "Code Wars"
"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)."
This is what my attempt to solve the problem looks like:
function powersOfTwo(n){
var myArray = [];
for (var i=0; i<=n; i++){
return myArray.push(2**i);
}
return myArray
}
However, it doesn't work, and I don't really understand why. I just started writing code last week to be honest.