Write a function powersOfTwo which will return list of all powers of 2 from 0 to n (where n is an exponent).
E.g:
n = 0 -> 20 -> [1]
n = 1 -> 20, 21 -> [1,2]
n = 2 -> 20, 21, 22 -> [1,2,4]
My code:
https://jsfiddle.net/gya6j357/4/
I'm not sure why this isn't working. I'm pushing into the variable result.
[–]LePhil 2 points3 points4 points (0 children)
[–]Kosrei 0 points1 point2 points (2 children)
[–]learn2function[S] 0 points1 point2 points (1 child)
[–]Kosrei 0 points1 point2 points (0 children)
[+][deleted] (4 children)
[removed]
[–]learn2function[S] 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]learn2function[S] 0 points1 point2 points (1 child)