suppose I have the following code:
var str = "4*(3)^2/1"
Is the simplest solution just to make a stack of the operators and solve with postfix notation? Or is there a really basic solution I'm missing.
Additionally how can I adapt if I'm using log, ln, sin, cos, and tan?
Sorry to respond to my own question, but the easiest solution is using math.js
var ans = math.eval(str);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With