Closed mattk410 closed 5 years ago
Yeah, this is true. When I was writing the code for the first time, my goal was to not use too many libraries, but now I think that it would be best to use the eval function from the Math.js library to evaluate expression instead of converting them into JavaScript code, which clearly is not scalable. Would you like to contribute?
I'd be happy to look into this later this week as well.
The convert function isn't working as expected due to incorrect replaces Example: expression = "exp(2)" The first if statement returns true (indexOf('e')) leading to expression = "Math.Exp(2)". The second if doesn't catch anything. Expression cannot be evaluated because it should be Math.exp(2).
There are also similar replacement problems with several of the trig functions too.