Skip to content

Instantly share code, notes, and snippets.

@miftahafina
Created September 14, 2018 14:48
Show Gist options
  • Save miftahafina/ebe8657cc9dad428b97d008189f2d7d5 to your computer and use it in GitHub Desktop.
Save miftahafina/ebe8657cc9dad428b97d008189f2d7d5 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