-
-
Save digitalconceptvisuals/70900f769c974ec39dfd62c726eb808f 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
/** | |
* Separate functions for each case conversion we support | |
* lower | |
* camel | |
* ... more will be added in future | |
*/ | |
function convertToLower(...words) | |
{ | |
let result = ""; | |
// Concatenate each element as lower | |
for (word of words) { | |
result += word | |
.toString() | |
.trim() | |
.toLowerCase(); | |
} | |
return result; | |
} | |
function convertToCamel(...words) { | |
let result = ""; | |
// first word is lower | |
result = words[0] | |
.toString() | |
.trim() | |
.toLowerCase(); | |
// Now rest of the words are Proper case | |
for (let offset = 1; | |
offset < words.length; | |
offset++) { | |
// First letter upper | |
result += words[offset] | |
.slice(0, 1) | |
.toUpperCase(); | |
// Rest all lower | |
result += words[offset] | |
.slice(1) | |
.toLowerCase(); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment