Repeating Letters N Times

Published by Helen Yu in

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

Watch a quick demo on how Edabit works.