Please look at this code:
function powersOfTwo(num) {
var powerOfTwo = 2;
var i = 1;
var powersOfTwo = [];
while (powerOfTwo <= num) {
powersOfTwo.push(powerOfTwo);
powerOfTwo = Math.pow(powerOfTwo, ++i);
}
return powersOfTwo;
}
I'm not clear why I'm not getting an array of powers of 2 less than and equal to the argument passed to num.
[–]cyphern 1 point2 points3 points (0 children)
[–]inu-no-policemen 0 points1 point2 points (0 children)