Closed RazvanBugoi closed 4 years ago
function isPowerOfTwo(n){
let num = 52;
let output = [];
for (let i=0; i<=num; i++) {
output.push(i);
}
let powersOfTwo = output.map((element) => Math.pow(2,element));
return powersOfTwo.includes(n);
}
I am pretty sure this is not the most efficient solution, but couldn't think of anything else at the moment.
https://www.codewars.com/kata/534d0a229345375d520006a0/train/javascript