title: Functional switch statement in Javascript
body: <p>Say I have a switch statement that takes a variable myData between 1 and some larger value, i.e. 300.</p>
  
  <p>Depending on the "status code" variable, the result is the text value of another variable. For example, if <code>myData == 1</code>, I want to return the a variable called <code>code1</code>. If <code>myData == 300</code>, I want to return the a variable called <code>code300</code>. Code1 and code300 variables store unrelated strings, i.e. "This is a summary", or "This is a note". Some psuedo-code below:</p>
  
  <pre><code>var myData = statusCode;
  
  var code1 = "This is a summary";
  var code300 = "This is a note";
  
  switch(myData) {
      case statusCode:
          scriptletResult = returnCode("code", statusCode); // code1 if myData == 1
          break;          
      default:
          scriptletResult = code1;
  }
  
  function returnCode(code, statusCode) {
      return code + statusCode; // Returns a variable "code1" if statusCode == 1
  }
  </code></pre>
  
  <p>How can I get this to work?</p>