JS Built-ins
← Math149 / 215
Mathlog2intermediate

Math.log2() β€” log2(1024) = 10

πŸ“– Usage Example
// Logarithm base 2
Math.log2(8)    // β†’ 3
Math.log2(256)  // β†’ 8

Use Math.log2() to compute the base-2 logarithm, useful for bit-length calculations and binary algorithms.

Math.log2()

Returns the base-2 logarithm of a number.

Challenge: Verify that Math.log2(1024) returns 10.

πŸ’‘ Hints (1)
  • β€’ log2(1024) = 10 because 2^10 = 1024