title: Using a switch with strings in JavaScript
body: <p>My <code>switch</code> statement is not working properly when analysing a string variable. </p>
  
  <p>The output and input are both <code>&lt;textarea&gt;</code>'s.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form name="interface"&gt;
    &lt;textarea name="output" rows="20" cols="100"&gt;&lt;/textarea&gt;&lt;br&gt;
    &lt;textarea name="input" rows="1" cols="100" onKeyDown="thinkInput(event);"&gt;&lt;/textarea&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>function thinkInput(e)
  {
      if (e.keyCode == 13)
      {
          sInput = document.interface.input.value;
          document.interface.output.value += sInput;
          aInput = sInput.split(" ");
  
          switch (aInput[0])
          {
              case "say":
                  textOut("You say \""+sInput.substring(aInput[0].length + 1)+"\"");
                  break;
              case "move":
                  move(aInput[1]);
                  break;
              default:
                  thinkFail();
                  break;
          }
          document.interface.input.value = null;
          alert(aInput[0]);
      }
  }
  </code></pre>
  
  <p>I can see in my <code>alert()</code> at the end that the case is either "say" or "move".  </p>
  
  <p>The first time I try to "say mudkipz" or "move around", everything works as I want it, but after that everything I type, <code>thinkFail()</code> fires.</p>