Welcome to my Calculator JavaScript practice project. We're happy to have you here 😄👀
- Project Overview
- Technologies Used
- My Approach
- Techniques Applied
- Problems Encountered
- Areas the Code can Be Improved
- Appeal for Tips
- Live Preview
This is just a normal Calculator game made by an amatuer for practice purposes. In this project I applied everything I have learned so far which are just beginner concepts of JavaScript. I know there are better ways to approach this project and I will continue updating the project as I learn more advanced concepts. I am also willing to learn from whatever advices and obdervations you may have for me regarding this project and my learning.
- HTML5
- CSS3
- JavaScript (Vanilla Js)
- When a button (that contains a number or simple arithmetic operator) is clicked the expression is collected and stored in the
expressionvariable - This variable is then evaluated when the equal button is pressed.
- When the backspace button is clicked, the
replace()replaces the last character in theexpressionvariable with an empty string. - If the eval button is clicked,
expressionbecomes equal toresult - Visual feedback is given (result is displayed)
In this project I attempted to create a Calculator game with vanilla js as a learning project using the following concepts
- I the
||operator shorthand in place of an if statement - I used the
eval()to evaluate expressions. - I used eventlisteners to run functions.
- I used the replace() to create a backspace button.
The drawback I am currently facing is adding a keydown event handler to the body to that will run the backspace function (del()).
I will look for methods to solve this now
- Add more functionalities like a memory to store past calculations, double display i.e display both expression and answer simultaneously on the screen.
I would really appreciate every tip offered on how to solve the problems I'm facing in the project. I will also appreciate tips on how I can write a more maintainable and clean code.