Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove last "return" statement #5628

Closed
AkiraLaine opened this issue Dec 31, 2015 · 6 comments
Closed

Remove last "return" statement #5628

AkiraLaine opened this issue Dec 31, 2015 · 6 comments

Comments

@AkiraLaine
Copy link
Member

Waypoint: Chaining If Else Statements

My code is all correct but it didn't want to pass. The error was "You should have five return statements" - so I removed the "change me" return statement and it passed.
But the instructions don't tell you to remove the last return statement.

My code:

function myTest(num) {
  // Only change code below this line
  if(num < 5){
    return "Tiny";
  } else if (num < 10){
    return "Small";
  } else if (num < 15){
    return "Medium";
  } else if(num < 20){
    return "Large";
  } else if(num >= 20){
    return "Huge";
  }
  return "Change Me"; //We need to remove this to pass
  // Only change code above this line
}

// Change this value to test
myTest(7);
@DDaems
Copy link
Contributor

DDaems commented Dec 31, 2015

Is there any reason why we are expliclity testing for 5 return statements? If not, i think we should remove it.

@ltegman
Copy link
Member

ltegman commented Dec 31, 2015

I'd agree with @DDaems that the return test is not necessary. If the code returns the correct answer and passes the if/else number tests that test isn't important.

@ltegman ltegman added help wanted Open for all. You do not need permission to work on these. confirmed first timers only Open for anyone doing contributions for first time. You do not need permission to work on these. labels Dec 31, 2015
@SaintPeter
Copy link
Member

I would change it to > 5 rather than === 5

@pbnj
Copy link
Contributor

pbnj commented Dec 31, 2015

@SaintPeter then anyone who would have exactly five would not pass either.

To remain as accurate as possible, I would change it to >= 5. Otherwise, if you want to keep it as >5, then we need to change the description to say "You should have more than five return statements."

@smrajagopal
Copy link
Contributor

@pmbenjamin : You are right my fix 63f324c actually has >=5

@pbnj
Copy link
Contributor

pbnj commented Dec 31, 2015

@smrajagopal, good enough for me!

ltegman added a commit that referenced this issue Dec 31, 2015
@ghost ghost removed help wanted Open for all. You do not need permission to work on these. first timers only Open for anyone doing contributions for first time. You do not need permission to work on these. labels May 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants