Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Created January 30, 2014 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilmoore/8705340 to your computer and use it in GitHub Desktop.
Save wilmoore/8705340 to your computer and use it in GitHub Desktop.
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