Number to Binary String in JavaScript

Level 130 keystrokes

Converts the number 10 to a binary string with toString(2) and prints it.

JavaScript code

// toString(2) writes the number in base 2, so 10 prints as 1010
1console.log((10).toString(2));

Output

1010
Practice typing this code

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.

  • (× 3
  • )× 3
  • .× 2
  • ;× 1

More JavaScript examples at level 1

← JavaScript typing practice