Skip to content

Instantly share code, notes, and snippets.

@Realtin
Last active December 12, 2017 14:36
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 Realtin/fba93c2bf63257b422445961085def9c to your computer and use it in GitHub Desktop.
Save Realtin/fba93c2bf63257b422445961085def9c to your computer and use it in GitHub Desktop.
// 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