Freecodecamp: Pseudocode "Break" Omission

Created on 31 May 2017  路  9Comments  路  Source: freeCodeCamp/freeCodeCamp

Challenge Adding a default option in Switch statements

In this challenge's pseudocode it does omits the "break;" statement where it is needed. This may be obvious and it's not a "bug" per se but I'm sure it could confuse some users who are new to programming.

Side note:

LOVE THIS SITE!!! THANK YOU FOR ALL YOUR HARD WORK!!!

switch (num) {
  case value1:
    statement1;
    break;
  case value2:
    statement2;
    break;
...
  default:
    defaultStatement;
}

edit: challenge is still passable, is break unecessary? sorry for the confusion.

first timers only help wanted

Most helpful comment

Hi @krisb1220

freeCodeCamp 鉂わ笍 you too! And thanks for reporting the issue.

In this challenge's pseudocode it does omits the "break;" statement where it is needed.

Both the case statements in the pseudo code have break statements. I am not sure what are you referring to.

Can you please clarify more?

All 9 comments

Hi @krisb1220

freeCodeCamp 鉂わ笍 you too! And thanks for reporting the issue.

In this challenge's pseudocode it does omits the "break;" statement where it is needed.

Both the case statements in the pseudo code have break statements. I am not sure what are you referring to.

Can you please clarify more?

Possibly referring to a missing break statement in the default case

Thanks, @jonathanihm with your comments and a second look I see what the OP means now, with this:

  1. The break statement is usually not required in case of the default, but
  2. JavaScript is funny, and if someone chose to write it say at the top then the case would fall through all cases until it hits a break statement.

However adding this clarification to instructions would confuse people further.

Should we just limit by adding a break to the default, and let it be?

I personally feel it's not necessary.

I'll let the @freeCodeCamp/moderators team add their thoughts on this.

I think we could add a break statement to the default case to make it clearer.

The fact that it's possible to omit break statements in some cases (for the last case, for default or when using return in case blocks) is a detail that campers can learn in the future.

I'd say we can open this for first time contributors! 馃檪

I agree with @raisedadead that adding additional explanation might just confuse campers. I agree with @Greenheart that the simplest thing to do would just be to add the break statement.

This is in keeping with our philosophy that we should try to communicate as little as absolutely necessary to get through the challenge, so as not to daunt or overload campers.

I've added the first-timers-only label to this.

@QuincyLarson we could make this change and add a side note somewhere saying that it's optional

@jonathanihm OK - I think we should just leave out the "optional" part. We don't tell campers that semicolons are optional, even though some developers argue that they are. IMHO The convention should be to include this for clarity.

@QuincyLarson I agree, I was just making a suggestion as this situation is not like semi-colons, as those are usually best practice and adding a break in the last case of a switch isn't.

@jonathanihm @QuincyLarson So we stay with just adding it in the end of the default clause? Because then I'd try to fix it - would be my first contribution to OpenSource ever :)

Was this page helpful?
0 / 5 - 0 ratings