I think you can even shorten (if I'm not mistaken) your solution by reducing one .map down and doing like me the surrounding in your first call to the .map method!
Should such a .surround method exist in String.prototype? I have came accross several cases where I would need it like in a WYSIWYG editor. But I don't want to risk proposing such a method to the community haha!
Good take btw!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I see we got a similar solution you and I!
I think you can even shorten (if I'm not mistaken) your solution by reducing one
.map
down and doing like me the surrounding in your first call to the.map
method!Should such a
.surround
method exist inString.prototype
? I have came accross several cases where I would need it like in a WYSIWYG editor. But I don't want to risk proposing such a method to the community haha!Good take btw!