Created
March 4, 2018 11:21
-
-
Save valeth/17f36323375e3920154b8a4de3bece33 to your computer and use it in GitHub Desktop.
JavaScript/CoffeeScript Snippets
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
titleize = (string) -> | |
tmp = string[0].toUpperCase() | |
for char in string.slice(1) | |
if char is char.toUpperCase() | |
tmp += " #{char}" | |
else | |
tmp += char | |
tmp |
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
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