Skip to content

Instantly share code, notes, and snippets.

@marcelo-ribeiro
Last active August 14, 2019 21:37
Show Gist options
  • Save marcelo-ribeiro/1316ee336d93af721b348e8efb8cc278 to your computer and use it in GitHub Desktop.
Save marcelo-ribeiro/1316ee336d93af721b348e8efb8cc278 to your computer and use it in GitHub Desktop.
Javascript String Capitalize
export const capitalize = value => {
if (!value) return "";
const list = value.toString().trim().split(" ");
list.forEach((item, index) => {
list[index] = item[0].toUpperCase() + item.slice(1).toLowerCase();
});
return list.join(" ");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment