Created
March 22, 2017 18:34
-
-
Save miguelmota/e3e12b612f77d59a949392c35856a583 to your computer and use it in GitHub Desktop.
JavaScript lodash capitalize all words
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
import _ from 'lodash'; | |
export default function capitalize(s) { | |
// lodash only capitalizes first word | |
return _.snakeCase(s).split(`_`).map(x => _.capitalize(x)).join(` `); | |
} |
return _.isEmpty('')
return _. snakeCase(''333 w3")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
_.isEmpty('')