Skip to content

Instantly share code, notes, and snippets.

@jordanhudgens
Created September 30, 2018 01:18
Show Gist options
  • Save jordanhudgens/e55d8c46ff164127d1cf29c27630fdf9 to your computer and use it in GitHub Desktop.
Save jordanhudgens/e55d8c46ff164127d1cf29c27630fdf9 to your computer and use it in GitHub Desktop.
const toCapital = str => {
const words = str.split(" ");
return words.map(word => word[0].toUpperCase() + word.slice(1)).join(" ");
};
const shortStr = "Hi there";
toCapital(shortStr); // Hi There
const longStr = "the quick brown fox jumped over the lazy dog";
toCapital(longStr); // The Quick Brown Fox Jumped Over The Lazy Dog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment