Last active
October 18, 2015 21:18
-
-
Save petekp/7bd327e611a28e98b566 to your computer and use it in GitHub Desktop.
Wrap all characters in a string with any XHTML tag (ES6, lodash)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
taggify(string, tag) { | |
let taggedChars = [] | |
_.map(string, function(char) { | |
taggedChars.push(`<${tag}>${char}</${tag}>`) | |
}) | |
return taggedChars.join('') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment