← Back to challenges

Repeating Letters N Times

JavaScriptHardstringsloopslanguage_fundamentals

Instructions

Create a function that repeats each character in a string n times.

Examples

repeat("mice", 5) ➞ "mmmmmiiiiiccccceeeee"

repeat("hello", 3) ➞ "hhheeellllllooo"

repeat("stop", 1) ➞ "stop"

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Exists a Number Higher?