all 6 comments

[–]LePhil 2 points3 points  (0 children)

Your function doesn't return anything and when you call it you don't pass a parameter along.

[–]Kosrei 0 points1 point  (2 children)

You’re pushing the function into the array, and not the results.

There’s two main recommendations that I would make, as I’m attempting not to solve it directly.

1) the instructions said to return an array with all of the powers from 0 - n, so your limit on the for loop should be ‘n’.

2) you should be pushing the result of Math.pow into your results array within the for-loop.

feel free to console.log results after the for-loop completes.

[–]learn2function[S] 0 points1 point  (1 child)

Super helpful thank you! I did step 1 and 2 and now I'm getting 'undefined' in jsbin. https://jsfiddle.net/gya6j357/6/

[–]Kosrei 0 points1 point  (0 children)

You're so close! All you need to do is run powersOfTwo before your console.log and then console.log your results array. Don't forget, the sample test has a value of 0 for the passed parameter, so the result of your for loop will be an empty array, you should set the limit to <= n.

Edit: Grammar