- Check if a value is classified as a boolean primitive. Return
true
orfalse
. - Boolean primitives are
true
andfalse
. - Hint: This program is very simple, the trick is to understand what a boolean primitive is. The programs requires a true or false answer.
- You will need to check for the type of the parameter to see if it is a boolean.
2.To check for the type of a parameter, you can use typeof.
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.
function booWho(bool) {
return bool;
}
booWho(null);
- Answer:
function booWho(bool) {
if (typeof bool === "boolean") {
return true;
}
return false;
}
console.log(booWho(null)); // will display false
Top comments (0)