diff --git a/snippets/check-for-boolean-primitive-values.md b/snippets/check-for-boolean-primitive-values.md new file mode 100644 index 000000000..308e3a085 --- /dev/null +++ b/snippets/check-for-boolean-primitive-values.md @@ -0,0 +1,8 @@ +### Check for boolean primitive values + +Use `typeof` to check if a value is classified as a boolean primitive. + +```js +const isBool = val => typeof val === 'boolean'; +// isBool(null) -> false +``` diff --git a/snippets/check_for_boolean.md b/snippets/check_for_boolean.md deleted file mode 100644 index a96719aea..000000000 --- a/snippets/check_for_boolean.md +++ /dev/null @@ -1,10 +0,0 @@ -### Check for Boolean Primitive Values - -Check if a value is classified as a boolean primitive. Return true or false. - -function booWho(bool) { - return typeof bool === 'boolean'; -} - -// test here -booWho(null);