Skip to content

Instantly share code, notes, and snippets.

@digitalconceptvisuals
Created July 30, 2020 19:50
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/70900f769c974ec39dfd62c726eb808f to your computer and use it in GitHub Desktop.
Save digitalconceptvisuals/70900f769c974ec39dfd62c726eb808f to your computer and use it in GitHub Desktop.
/**
* 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