2.&) to determine if n is a power of 2.n is not falsy.const isPowerOfTwo = n => !!n && (n & (n - 1)) == 0;
isPowerOfTwo(0); // false
isPowerOfTwo(1); // true
isPowerOfTwo(8); // trueSubscribe to get resources directly to your inbox. You won't receive any spam! ✌️