Split and Delimit

Published by Helen Yu in

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

Watch a quick demo on how Edabit works.