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
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.
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