Created
January 30, 2014 09:35
-
-
Save wilmoore/8705340 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module.exports = spacify; | |
/** | |
* Separate characters in a string with a space. | |
* | |
* @param {String} str | |
* string to transform. | |
* | |
* @return {String} | |
* Space separated string. | |
*/ | |
function spacify(str) { | |
return toArray(str).join(' '); | |
} | |
/** | |
* Get the array representation of a string. | |
* | |
* @param {String} str | |
* string to transform. | |
* | |
* @return {Array} | |
* array representation of string. | |
*/ | |
function toArray(str) { | |
return Array.prototype.slice.call(str || ''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment