Skip to content

Instantly share code, notes, and snippets.

@valeth
Created March 4, 2018 11:21
Show Gist options
  • Save valeth/17f36323375e3920154b8a4de3bece33 to your computer and use it in GitHub Desktop.
Save valeth/17f36323375e3920154b8a4de3bece33 to your computer and use it in GitHub Desktop.
JavaScript/CoffeeScript Snippets
titleize = (string) ->
tmp = string[0].toUpperCase()
for char in string.slice(1)
if char is char.toUpperCase()
tmp += " #{char}"
else
tmp += char
tmp
function titleize(string) {
tmp = string[0].toUpperCase();
for (char of string.slice(1)) {
if (char === char.toUpperCase()) {
tmp += ` ${char}`;
} else {
tmp += char;
}
}
return tmp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment