Instantly share code, notes, and snippets.

Embed
What would you like to do?
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