I am building a conversion calculator. I would like to store the references and formulas for the calculator in JSON.
I do not know how to “process the variable as math”.
Json
var JSON = {
"conversions": [{[
{
"FromType": "in3",
"ToType": "ft3",
"Math": "/1728",
"Description": "divide the volume value by 1728"
}...
With the “Math” being done something like this.
D1 = document.getElementById("data1").value;
var theAnswer = eval(D1 conversions[0].Math);
Example:
D1 = 25
theAnswer = D1 /1728
theAnswer = 0.0144675
Is this possible? Is there a better way?