Is this ok? - Basic Algorithm Scripting - Boo who

I checked the hints page and solution given after solving. Looks like I was supposed to use typeof. I know my code passed, but I have the feeling that I shouldn’t have used the solution I used. Is my solution acceptable or did I find a bug lol

function booWho(bool) {
  if (bool === true | bool === false) {
    return true;
  } else {
  return false;


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic Algorithm Scripting - Boo who

Link to the challenge:

Looks like I was supposed to use typeof.

I don’t know about “supposed to”. You were supposed to write a function that fulfilled the test requirements, which you did.

I mean, what you did works. There are only two possibilities and you used === so it won’t coerce. My only complaint is that you should have used || instead of |.

Also, instead of if you could just return the results of your test:

return (test)

But it works.

Is it better?

I think using the typeof is better because it is much clearer what you are testing. Writing code that tells you what it is doing is almost always better.

But that’s all part of the learn ing process.

I added [spoiler][/spoiler] tags around your code since it is a working solution.

Thank you @kevinSmith. I’ll remember to do the spoiler tags moving forward. I just finished the next challenge (Title Case a Sentence) and can tell I’m going to need to do a lot of refinement on my code before being able to be an effective programmer. All of my solutions seem to end up with twice as many or more lines of code compared to the solutions given. Pretty ugly

It’s normal to be writing sloppy code at this point. You’re still learning.

And don’t assume that smaller is better. Yeah, it’s a good thing to shoot for, but a lot of times I worry more about clarity, being easy to read.

It comes with time, just people practicing. You’re on the right path.

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