I am building a simple Javascript calculator that calculates strings by using eval(). There are a couple of issues that I am running into.
- If I run something like eval("023 + 11")that returns 30. Should I be expecting 24 instead?
- I have a option to convert a percentage into a decimal eval("025 * 0.01")that returns 0.21 when I am expecting 0.25
- Running certain numbers like eval("0.7 * 0.01")returns 0.006999999999 when I am expecting 0.007. Other times when I runeval("0.25 * 0.01")return 0.0025, which is correct.
When I deploy this, I am worried about other issues from eval() that might result in a incorrect calculation. Are there any other issues that users might encounter. Are there any better ways to build the calculator? How would I fix the issues I am having (I guess for inputs starting with 0 that's not a decimal I could strip the 0)?
