-
-
Save digitalconceptvisuals/6a89dd08afed8c22b37268d80182a53a 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 new functionality does not require modify "code" | |
* We can simply update our map with new case converter | |
*/ | |
function changeCase(word, caseType) { | |
const caseMap = { | |
"lower": convertToLower, | |
"camel": convertToCamel, | |
"proper": convertToProper | |
} | |
// Convert switch case to map(string, function) | |
caseType = caseType.trim().toLowerCase(); | |
var conversion = caseMap[caseType]; | |
// Make sure we got the conversion function | |
return conversion? caseMap[caseType](word) : null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment