Skip to content

Instantly share code, notes, and snippets.

@digitalconceptvisuals
Created July 30, 2020 19:57
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 digitalconceptvisuals/2bd45ddc0f2713bf0999a3b9189f0111 to your computer and use it in GitHub Desktop.
Save digitalconceptvisuals/2bd45ddc0f2713bf0999a3b9189f0111 to your computer and use it in GitHub Desktop.
/**
* Adding a new case converter called Proper case
* Proper case is also called Pascal case
* Where every word begins with an upper case
* All the remaiing letters of the words are lower
*/
function convertToProper(...words) {
// Proper case is also called PascalCase
// Every word starts with an upper letter
// All the remaining letters are lower
let result = "";
// Go thru every word
for (word of words) {
// First letter is upper
result += word
.slice(0, 1)
.toUpperCase();
// Rest all are lower
result += word
.slice(1)
.toLowerCase();
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment