Tell us what’s happening:
My code returns false everytime.Why is this happening.
Your code so far
function booWho(bool) {
if (typeof bool = Boolean) {
return true;
}
else {
return false;
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/boo-who
lekha
2
you’ve only used one “=” so it thinks you’re trying to assign “bool” to “Boolean” which is invalid
edit: more on how to use typeof with proper equals checking: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof
isnt working even after using ‘==’ or ‘===’.
lekha
4
If you take another look at the link, you’ll see that typeof
won’t return Boolean
like you’re checking for. See here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#Description