String Pad Start in JavaScript

Level 134 keystrokes

padStart(3, "0") adds zeros in front of "5" until it is 3 characters long, printing "005".

JavaScript code

// padStart(targetLength, padString) adds padString in front until the length is reached
// "5" gets two "0"s and becomes "005"; already-long strings are left as they are
1console.log("5".padStart(3, "0"));

Output

005
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.

  • "× 4
  • .× 2
  • (× 2
  • )× 2
  • ,× 1
  • ;× 1

More JavaScript examples at level 1

← JavaScript typing practice