title: How can I convert a string into a math operator in javascript
body: <p>If I've got a string that is a mathematic equation and I want to split it and then calculate it. I know I can use the eval() function to do this, but I'm interested if there's an alternative way to do this - specifically by splitting the strings first. So I've got something like</p>
  
  <pre><code>var myString = "225 + 15 - 10"
  var newString = myString.split(" ");
  </code></pre>
  
  <p>This would turn myString into an array: </p>
  
  <pre><code>["225", "+", "15", "-", "10"];
  </code></pre>
  
  <p>My next task is to turn all the odd-numbered strings into integers, which I think I could use parseInt(); for. My question is, how do I turn the "+" and "-" into actual arithmetic operators? So that at the end I am left with a mathematic expression which I can calculate?</p>
  
  <p>Is this possible?</p>