title: Using Switch Statements in Javascript
body: <p>Okay big question about switch statements. I'm new to JS.</p>
  
  <p>I'm trying to make a switch statement that takes input from an input box, looks for "Multiplication" "Subtraction" "Addition" and "Division" among letters and numbers in the input string and separates non-numbers from numbers and then does the typed operation on the set of numbers. So for instance, the input box might look like this: </p>
  
  <pre><code>1 a 2 b 3 c 4 multiply d 5 e
  </code></pre>
  
  <p>So far, I've been able to separate numbers from non-numbers into arrays that would look like this given the input above: </p>
  
  <pre><code>numberArray === [1,2,3,4,5]
  letterArray === [a,b,c,multiply,d,e]
  </code></pre>
  
  <p>and I have functions set to add, subtract, multiply, and divide the number array, so how would I incorporate using a switch statement to find one of those many possible inputs in my array of letters? </p>
  
  <p>Another thing, all the loops used for the mathematical operations are similar, for instance, subtraction looks like this: </p>
  
  <pre><code>for (; i &lt; numberArray.length; i++ ) {
      if (i === 0) {
          sub = numberArray[0]
      } else {
          sub = sub - numberArray[i]
      }
  }
  </code></pre>
  
  <p>and multiplication looks like this:</p>
  
  <pre><code>   for (; i &lt; numberArray.length; i++ ) {
      if (i === 0) {
          sub = numberArray[0];
      } else {
          sub = sub * numberArray[i];
      } 
  }
  </code></pre>
  
  <p>Would it be possible to use the same switch statement to consolidate all four operation functions into one function, instead of calling each separate function for each case? </p>
  
  <p>Edited to explain my letter and number arrays, also to change the title and tags from another topic that was entirely unrelated.</p>