String Repeat in JavaScript

Level 128 keystrokes

repeat(3) joins three copies of "Ha" and prints "HaHaHa".

JavaScript code

// repeat(n) returns a new string made of n copies of the original
// "Ha" three times gives "HaHaHa"; repeat(0) would return ""
1console.log("Ha".repeat(3));

Output

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

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

More JavaScript examples at level 1

← JavaScript typing practice