Skip to content

Instantly share code, notes, and snippets.

@miftahafina
Created September 14, 2018 14:49
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 miftahafina/ca8260b64d0c8680f714ec9895eff6c6 to your computer and use it in GitHub Desktop.
Save miftahafina/ca8260b64d0c8680f714ec9895eff6c6 to your computer and use it in GitHub Desktop.
let ucwords = (str) => {
return str.toLowerCase()
.split(' ')
.map((x) => x.slice(0, 1).toUpperCase() + x.slice(1, x.length))
.join(' ');
}
let tes = ucwords("loReM iPsum DolOr SIt aMet");
console.log(tes); // result: "Lorem Ipsum Dolor Sit Amet"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment