Check if a value is classified as a boolean primitive. Return true or false.
Boolean primitives are true and false.
function booWho(bool) {
return bool;
}
booWho(null);
This are the tests:
booWho(true) should return true.
Waiting:booWho(false) should return true.
Waiting:booWho([1, 2, 3]) should return false.
Waiting:booWho([].slice) should return false.
Waiting:booWho({ "a": 1 }) should return false.
Waiting:booWho(1) should return false.
Waiting:booWho(NaN) should return false.
Waiting:booWho("a") should return false.
Waiting:booWho("true") should return false.
Waiting:booWho("false") should return false.
My tries:
function booWho(bool) {
return (bool == true||false)
}
booWho(null);
function booWho(bool) {
return (bool == true|| bool == false)
}
booWho(null);
this two gives me a problem with this test: booWho(1)
should return false
function booWho(bool) {
return (bool === true||false)
}
booWho(null);
this one gives me a problem with this test: booWho(false)
should return true.
I ended up passing with typeof
, but i have no idea why the others are giving errors, thanks in advanced