I would like to get some feedback on my JS calculator. I also have some follow up questions.
The use of “eval( )” ?
The trickiest part to this challenge is building out the JS button logic for computing the numbers and cleaning the equation string to make it work. I created a series of “if-then” statements, but I definitely think that the logic could be written more cleanly. Is there a better way to write the button logic, maybe through switch statements, that make it more elegant?
Calculating the string equation at the “equals” button
I decided to calculate the equation string only when the user hits the “equals” button. I noticed that the calculator app on my android phone can return the answer “in real time”, as I am typing the equation. Any potential explanation on how they did that?