log2intermediate// Logarithm base 2
Math.log2(8) // β 3
Math.log2(256) // β 8Use Math.log2() to compute the base-2 logarithm, useful for bit-length calculations and binary algorithms.
Returns the base-2 logarithm of a number.
Challenge: Observe that Math.log2(0) returns -Infinity.