Skip to content

Instantly share code, notes, and snippets.

@talentedaamer
Last active February 3, 2019 19:21
Show Gist options
  • Save talentedaamer/5d1c21719225e4c626abeb499692931c to your computer and use it in GitHub Desktop.
Save talentedaamer/5d1c21719225e4c626abeb499692931c to your computer and use it in GitHub Desktop.
ucWords in JavaScript.
/**
* uppercase words in string.
*
* @param str
* @returns {string}
*/
export function strUcWords ( str ) {
return ( str + '' ).replace(/\b[a-z]/g, function (letter) {
return letter.toUpperCase()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment