I have a input field
where user can write equation like 3+4-2 etc.
Using jquery
I can retrieve the value of input field like this:
var eqn = $("input").val();
Variable eqn
contain 3+4-2, I have to display it as 5(by solving) not as 3+4-2. How to display the equation as result?
Equation may contain the symbols +,-,*,/,.
etc.
Since the variable eqn
is string type
it display as 3+4-2. When I use parseFloat
it display as 3. So this can't be use.