Created
March 22, 2018 20:39
-
-
Save nickihastings/6fb2b02cbe910a8e938a0c3e1f6ca508 to your computer and use it in GitHub Desktop.
Check if a value is classified as a boolean primitive. Return true or false. Boolean primitives are true and false.
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
function booWho(bool) { | |
// What is the new fad diet for ghost developers? The Boolean. | |
//check if the value 'bool' is strictly true or false, this means the value is a Boolean Primitive and should return true. | |
//Everything else should return false. | |
if(bool === true || bool === false){ | |
return true; | |
} | |
else { | |
return false; | |
} | |
} | |
booWho(null); |
we can use simply this :
function booWho(bool) {
return typeof (bool) ==="boolean"
}
booWho(null);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you buddy.