Skip to content

Instantly share code, notes, and snippets.

@nickihastings
Created March 22, 2018 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nickihastings/6fb2b02cbe910a8e938a0c3e1f6ca508 to your computer and use it in GitHub Desktop.
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.
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);
@saman-taghavi
Copy link

saman-taghavi commented May 30, 2021

dude loved your gist! 👍
here is my version based on yours

function booWho(bool) {
  return (bool === true || bool === false)
}

booWho(null);

@cyborg595
Copy link

Thank you buddy.

@firemanx07
Copy link

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