Error in challenge

Was pulling my hair out until I gave in and clicked on the solution. The example in this challenge is wrong and wont pass you if you follow it.

I don’t understand what you mean. The example is correct but cannot be simply copy-pasted into the challenge as the answer.

I don’t understand. The example is an of how switch works, not a cut and paste solution. The learner is supposed to understand that the input and action will be different.

What information do you think is missing or what do you think is misleading?

I understand that the input and action will be different. My input and actions reflected the requirements to complete the challenge. I didn’t just copy and paste the example and call it a day.

What didn’t pass me was the semicolon placement. In the example it’s after the string. In the solution it’s before the string.

In the solution you need to put the semicolon after the string as well.

Sorry I meant colon. In the example the colon was after the string. That didn’t pass. Solution colon was before the string. That passed.

The colon is in the correct place too…
case SomeValue:

Trying to use case :someValue would be broken code.

Can you show us the complete code that you think should pass but doesn’t?

Trying to mimic the example with my own inputs and actions, this is what I came up with.

switch(val) {
  case 1 "alpha":
    return "Alpha";
  case 2 "beta":
    return "Beta";

The point wasn’t to “mimic” the example but to understand how a switch works.

I think you needed to read and understand the description better.

I’m not saying this to come down on you - we all have little stumbling blocks.

1 Like

Ok, but that isn’t what is in the example.

  case "a":

I understand the theory. I mimic so that I can make correct placements because I’m brand new to coding.

I found this challenge not very well explained.

Yeah, I get what you’re saying. And we’re not trying to come down on you - we remember what it was like. I think it is adequately written, but perhaps after you get some more experience you an revisit it and see if you can suggest some improvements.

1 Like