This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Control Flow: Switch Forum

View Course » View Exercise

863 points
551865b8d3292fdcfd004343_976277809
Submitted by
Dania
about 2 years ago

6/6 Seems to have some sort of bug

Looking at all the questions, it's pretty apparent that 6/6 is broken somehow. It's looking for unreasonable parameters or something because I've looked through the questions and a lot of people have had the issue.

I've had similar issues with the JavaScript tutorial where proper code didn't go through and I had to go to the forums for an exact copy and paste job to get to the next step. I think it has something to do with how the browser is handling the code as you type, because it's happened where I refresh and paste whatever I just did and it works all of a sudden. I've also managed to have old code still run after I've deleted it.

Just something to look at. After browsing for an answer, this works:

$i=3
switch($i):
case 1:
case 2:
case 3:
echo "i is between 1 and 3";
break;break;break;
default:break;
endswitch;

I got it from this answer.


2 votes

permalink

While I applaud codeacademy.com for providing such a great (and free) resource for learning programming, I will say that it is frustrating when you write perfectly valid code and the editor does not approve it and allow you to continue. I provided the following switch statement for this exercise which is 100% valid (and validates and functions in other PHP testing sites, like PHPTESTER.net) but does not here for whatever reason:

    <?php


    $dog = "doggie";

    switch($dog) {
        case "Woodle":
            echo "That's a woodle!";
            break;

        case "Lab":
            echo "That's a lab!";
            break;

        case "German Shepard":
            echo "That's a German Shepard!";
            break;

        default:
            echo "You need to give me a dog I know!";

    }

?>

313 points
C0a9c297a6a9354c5c01c03f45a331a5?s=140&d=retro
Submitted by
iboersma
about 2 years ago

4 Comments

5674c6dae39efec455000434_879409444 Zeke Y about 2 years ago

Refresh the page && try again :)

C0a9c297a6a9354c5c01c03f45a331a5?s=140&d=retro iboersma about 2 years ago

Thanks, Zeke. I tried that several times and it still didn't work. What's strange is that I am not getting an error, but the blue 'submit' button is just showing the white "gear" icon after clicking. The result pane on the right is actually showing the correct output of the script, so I'm really puzzled...

5674c6dae39efec455000434_879409444 Zeke Y about 2 years ago

Are you getting any connection errors?

C0a9c297a6a9354c5c01c03f45a331a5?s=140&d=retro iboersma about 2 years ago

Well, I closed my browser and re-logged in and re-copied the same switch statement above and it worked this time. Go figure... Thanks for trying to help, Zeke.


1 vote

permalink

Hi Dania,

It's looking for unreasonable parameters

Not at all. The instructions for 6/6 are very clear and easy to follow if you've been paying attention.

it's happened where I refresh and paste whatever I just did and it works all of a sudden.

You probably just needed to wait a few seconds for the code to update before refreshing, but yes, that's a common procedure for debugging a problem.

After browsing for an answer, this works:
$i=3
switch($i):
case 1:
case 2:
case 3:
echo "i is between 1 and 3";
break;break;break;
default:break;
endswitch;

That code is terrible. It doesn't pass for me, and the only reason it passes for you is because it's so terrible you broke the SCT (Submission Correctness Test; code checker).
It's pretty easy to write a valid switch statement that will pass you and not throw a PHP error. If you don't remember how, look at step 2/6 :)

2818 points
5674c6dae39efec455000434_879409444
Submitted by
Zeke Y
about 2 years ago


0 votes

permalink

Hi Dania,

There are a lot of problems with this course and people have been raising them for a long time. For some reason it looks like the editor doesn't always update its memory to the most recent code you've entered.

If you could post a copy of your code for it before you used the answer above someone might be able to see if it was an error with the code or the editor (probably the editor but you never know).

Tim

1115 points
9092398c5ae8ff80b6254d0d275ce55b?s=140&d=retro
Submitted by
Tim Fawkes
about 2 years ago


0 votes

permalink

GO TSM! GO TSM!

210 points
55515fa386f552e3f10000fb_741959156
Submitted by
Tason Jran
about 2 years ago

5 Comments

5535adf951b887899500058e_964357971 Yiliang Peng about 2 years ago

GO CLG! GO CLG!

5535adf951b887899500058e_964357971 Yiliang Peng about 2 years ago

CLG > TSM

55515fa386f552e3f10000fb_741959156 Tason Jran about 2 years ago

TSM WildTurtle > CLG DoubleLift

5535adf951b887899500058e_964357971 Yiliang Peng about 2 years ago

thats why im on 30 points

55515fa386f552e3f10000fb_741959156 Tason Jran about 2 years ago

Thats why CLG came 5th, and TSM cant 1st ;)


0 votes

permalink

GO CLG! GO CLG!

209 points
5535adf951b887899500058e_964357971
Submitted by
Yiliang Peng
about 2 years ago