I tried this in jade served by express but got “unexpected identifier” as an error.
- switch(myvar)
- case: "0"
span First Case
break
- case: "2"
span Second Case
break
- case: "3"
span Third Case
break
- case: "4"
span Fourth Case
break
I was curious as to what is the syntax for a switch statement, if there is one.
Update: Jade, not express.
EDIT
This question is apparently about Jade instead.
But the answer is still yes :).
But it’s called
case:From the docs
Javascript has a switch statement.
Being that Express.js runs in Node.js which is just JavaScript — yes. Express has a
switchstatement since JavaScript has aswitchstatement. (Even coffeescript has aswitchthat “compiles” down to a JavaScriptswitchstatement.)MDN reference:
switchstatementIt looks like your syntax is messed up there — what are those “-” characters? You’re also missing the
:from the end of eachcasestatement, and you’re notbreaking after each case which means the code for ALL cases will ALWAYS run regardless of the condition.