Last active
December 12, 2017 14:36
-
-
Save Realtin/fba93c2bf63257b422445961085def9c 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
// Version 1.0.0 | |
function changeCase (theString) { | |
return theString.toUpperCase() | |
} | |
// Version 1.1.0 (Feature) | |
function changeCase (theString, allowLowerCasing = false) { | |
if (allowLowerCasing && theString.toUpperCase() === theString) { | |
return theString.toLowerCase() | |
} | |
return theString.toUpperCase() | |
} | |
// Version 2.0.0 (Breaking) | |
function changeCase (theString, allowLowerCasing = false) { | |
if (theString.match(/\d+/g)) { | |
return new Error('No Numbers allowed!') | |
} | |
if (allowLowerCasing && theString.toUpperCase() === theString) { | |
return theString.toLowerCase() | |
} | |
return theString.toUpperCase() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment