-
-
Save digitalconceptvisuals/2bd45ddc0f2713bf0999a3b9189f0111 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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