← Back to challenges

Repeating Letters

JavaScriptHardstringsformatting

Instructions

Create a function that takes a string and returns a string in which each character is repeated once.

Examples

doubleChar("String") ➞ "SSttrriinngg"

doubleChar("Hello World!") ➞ "HHeelllloo  WWoorrlldd!!"

doubleChar("1234!_ ") ➞ "11223344!!__  "

Notes

All test cases contain valid strings. Don't worry about spaces, special characters or numbers. They're all considered valid characters.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: RegEx XV : Group Ranges - Negated Character Sets