Type difference?

Tell us what’s happening:
So I got the answer and wrote practically the same solution as this one, but one thing I don’t understand is if it uses a ‘===’, how does it work equaling a string, “boolean”? true/false is a boolean value but “boolean” is a string. In my solution I used a ‘==’.
Your code so far


function booWho(bool) {
return typeof bool === "boolean";
}

booWho(null);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36.

Challenge: Boo who

Link to the challenge:

typeof gives you the string of the type so for a boolean value it returns 'boolean'
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.