Skip to content

Instantly share code, notes, and snippets.

@Realtin Realtin/example.js
Last active Dec 12, 2017

Embed
What would you like to do?
// 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
You can’t perform that action at this time.