Skip to content
This repository was archived by the owner on Feb 20, 2019. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/flip-bool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint prefer-spread:0 */
export default flipBool

/**
* Original Source:
* https://github.com/eggheadio-github/stack-overflow-copy-paste/issues/251

* This method will take a boolean value and reverse its value.
*
* @param {bool} boolArg - the bool that will be mutated
* @return {bool} boolArgv - the bool that was mutated
*
* Takes a bool value and checks to see if it's data type is boolean. If true,
* it will reverse the value of the passed boolean and return that value. If
* false, it returns a string with the value 'boolean expected'.
*/

function flipBool(boolArg) {

if (typeof (boolArg) === 'boolean') {

if (boolArg === true) {
boolArg = false
} else {
boolArg = true
}
return boolArg
} else {
return 'boolean expected'
}
}