Variables in javascript switch cases?
<p>I want to use variables as the values for each case in a switch statement, but it doesnt seem to work:</p>

<pre><code>switch(key) {  

    case keyNext: 
      //go to next
      break;

    case keyPrev: 
      //go to prev
      break;
}
</code></pre>

<p>I really need the switch statement because unlike in this example, I have lots of different cases.</p>

<p>Why doesnt this work? Any workarounds for it?</p>

<p><strong>EDIT</strong>: as said in the answers, this is perfectly valid. I was using properties of an object as the values for each case, and there was a syntax problem with it.</p>
