Testing an equation in JavaScript
<p>How can I test if a mathematical expression is true?</p>

<pre><code>var equation = "1 + 1 = 2";
if (equation === true){
  document.write("1 + 1 = 2");
}else{
  document.write("1 + 1 =/= 2");
}
</code></pre>

<p>For obvious reasons, this code ^^^ doesn't work, but I just wanted to know if there was a function that would do this; evaluate a mathematical expression then return its verity as a boolean (true/false).</p>
