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

Control Flow: Switch Forum

View Course » View Exercise

1145 points
Picture
Submitted by
Jihun Jeong
over 4 years ago

Using the switch statement: What did i do wrong?

switch ($i) {
case 0:
echo '$i is 0.';
break;
case 1:
case 2:
case 3:
echo '$i is somewhere between 1 and 3';
break;
case _:
case 5:
echo '$i is somewhere between 1 and 5.';
break;
case 6:
case 7:
echo '$1 is either 6 or 7.';
break;
default:
echo "I don't know how much \$i is";
break;

am not sure what i did wrong with this code


0 votes

permalink

case _:
case 5:

There is an underscore there instead of a 4. Also add the closing } at the end of this if you haven't.

591 points
Ba74e27259fa04660fa2782c02db260b?s=140&d=retro
Submitted by
adobery
over 4 years ago