Control Flow- Switch question/bug report


I'm stuck at the last execrise on the top mentioned section. It requires you to build an switch statement with 3 different cases and a optional default case. My code is as follows:

<!DOCTYPE html>
     $i= "red";  
     switch ($i) {
        case "brown";
        echo "$i is not the answer."; 
        case "green";
        echo "$i is not it.";
        case "red"; 
        echo "$i is the answer."; 
        echo "It's none of them."; 

It just outputs that I need three case blocks, which I do have, looking at the top code.


after your case declarations (e.g. "red", "green" etc.) add a colon ':' instead of a semicolon ';'
the default case will need to be changed as well.

Remember that a semicolon ';' ends a statement.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.