It’s OK, we all get to point where something drives us crazy. I was where you are two years ago. After two years of hard work, I now do this for a living. YMMV.
I’m not sure what you mean by “strict conditional”. Do you mean using
=== instead of
==? I’ll get to that in a second.
Also, I had no way of knowing that I shouldn’t call the function caseInSwitch() inside my switch statement, instead switch(val) is the correct syntax.
You have the function calling itself. That is an advanced technique called “recursion” and is definitely not what you want here. The prototype they offer has:
Notice that it is not calling a function there, just using a value, in this case the variable num.
If strict conditionals are important, where would they go?
That is the other problem with the code presented. Notice in the example. it’s
case: value1, not
case: conditional1. With an
if statement you can do conditionals and complex calculations. With
switch it is just one, single value (or something that evaluates to a single value). So you want
case: 1. Also notice the placement of the colon.
Don’t get frustrated. This is hard stuff. If it were easy, then anyone could do it and it would pay minimum wage. The wages are high because most people don’t have the patience to learn.
If you are still stuck, let us know. When I make those changes to your code, it passes for me.