Logarithm Base 2 in JavaScript
Level 127 keystrokes
Math.log2() returns the base-2 logarithm of 32 and prints 5.
JavaScript code
// Math.log2(x) answers "2 to what power equals x?"// 2 ** 5 = 32, so 5 is printed; useful for counting bits or halving steps1console.log(Math.log2(32));Output
5
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this JavaScript code and how often they appear.
.× 2(× 2)× 2;× 1