JS Built-ins
MathLN2intermediate

Math.LN2 β€” use in log base 2 calculation

πŸ“– Usage Example
// Natural logarithm of 2
Math.LN2          // β†’ 0.6931471805...
Math.log(2) === Math.LN2   // β†’ true

Use Math.LN2 as a precomputed constant when converting between natural and base-2 logarithms.

Math.LN2

Divide Math.log(n) by Math.LN2 to compute logβ‚‚(n).

Challenge: Use Math.LN2 to compute base-2 logarithms.

πŸ’‘ Hints (2)
  • β€’ logβ‚‚(n) = Math.log(n) / Math.LN2
  • β€’ This works for any positive n.