Skip to content

Instantly share code, notes, and snippets.

@digitalconceptvisuals
Created July 30, 2020 19:51
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/1eec2493ff5afd8542dbda491b872ba1 to your computer and use it in GitHub Desktop.
Save digitalconceptvisuals/1eec2493ff5afd8542dbda491b872ba1 to your computer and use it in GitHub Desktop.
/**
* Our main function has simplied a lot
*/
function changeCase(word, caseType) {
// We create a map of caseType -> function
const caseMap = {
"lower": convertToLower,
"camel": convertToCamel
}
// Look up the caseType "lower", "camel"
// The map will return its function, call it
caseType = caseType.trim().toLowerCase();
var conversionFunction = caseMap[caseType];
// Do we have this conversion function?
if ( conversionFunction != null )
return conversionFunction(word);
else
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment