Javascript Calculator Project from "The Odin Project"
This project is to make a completely functional calculator using javascript. View Here
In order to build the calculator, I used a combination of html, css and javascript.
- Completely functional basic calculator
- Intuitive Design
- Intuitive Keyboard support
- Error message when trying to divide by zero
- Disallows multiple operators to be entered consecutively
- Allows calculation of multiple operands
- Allows brackets to be used in calculations
This project allowed me to implement javascript basics. There was a strong focus on string manipulation to handle the numbers for display and for calculation, and adding event listeners since the calculator required human input.
There were 2 main issues which consumed alot of my time. The first one being bugs kept on popping up, and having to go back and debug code took a significant amount of time.
However, the most time consuming aspect of this project was implementing a "Shunting Yard Algorithm" to convert the original infix expression entered by a human to postfix expression for computer calculation.
The first challenge was that I had to figure out what a shunting yard algorithm was. This was fairly straightforward, and took about a day to fully grasp the concept.
Implementing a creating it however was a much more difficult task, and took me about a week.
In doing so however, I learnt a great deal about string to number conversion, and vice versa, as well as implementing objects and arrays for data storage and usage.