shrey183 / Symbolic-Calculator

This is an ongoing project to create a symbolic calculator.
MIT License
2 stars 10 forks source link

Convert function not working #15

Closed mattk410 closed 5 years ago

mattk410 commented 5 years ago

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.

shrey183 commented 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?

mattk410 commented 5 years ago

I'd be happy to look into this later this week as well.