Wrong example for "Selecting Many Options With Switch Statements"

Tell us what’s happening:
The example code for this lesson, seen here:

switch(num) {
  case value1:
    statement1;
    break;
  case value2:
    statement2;
    break;
...
  case valueN:
    statementN;
    break;
}

is not a correct example, since you have to number each case as you go. Even rather, the case value1, 2, etc is not a good example since it’s just case 1:, case 2:, case 3:, etc. I feel like the case value1 etc. implies that there’s supposed to be something before the number as well, which is not the case.

Just thought I’d put this out there so maybe the developers can review it.

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/selecting-from-many-options-with-switch-statements

Here is a pseudocode example:

That is just before the code block you are referencing. The point of pseudocode is to give the concept of code, without worrying about whether its a String or a Number or a Boolean. It simply gives the idea of what the code would do.

Obviously, the ellipsis (...) would be invalid code too, were this intended to be working code. But this is one of the first lessons to really start talking about ‘pseudocode’, which is a very useful, powerful tool that more developers really could benefit from.

1 Like