You will need to check for the type of the parameter to see if it is a boolean.
Hint 2
To check for the type of a parameter, you can use typeof.
Hint 3
Since you must return true or false you can use if statements or just have it return the boolean used for the if statement.
Solutions
Solution 1 (Click to Show/Hide)
function booWho(bool) {
return typeof bool === "boolean";
}
// test here
booWho(null);
Code Explanation
Uses the operator typeof to check if the variable is a boolean. If it is, it will return true. Otherwise, if it is any other type it will return false.
I didn’t remember that typeof returned a string, so I couldn’t figure out the suggested solution.
Instead I did something a little overly complicated,
function booWho(bool) {
let test = true;
return typeof bool === typeof test;
}
function booWho(bool) {
// What is the new fad diet for ghost developers? The Boolean.
if(typeof(bool)==="boolean"){
return true;
}
else{
return false;
}
}
booWho(null);