isPowerOfTwo
Checks if the given number is a power of 2
.
- Use the bitwise binary AND operator (
&
) to determine ifn
is a power of2
. - Additionally, check that
n
is not falsy.
Checks if the given number is a power of 2
.
&
) to determine if n
is a power of 2
.n
is not falsy.