← Back to challenges

Split and Delimit

JavaScriptHardstringsregex

Instructions

Write a function that splits a string into substrings of size n, adding a specified delimiter between each of the pieces.

Examples

splitAndDelimit("bellow", 2, "&") ➞ "be&ll&ow"

splitAndDelimit("magnify", 3, ":") ➞ "mag:nif:y"

splitAndDelimit("poisonous", 2, "~") ➞ "po~is~on~ou~s"

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.