Monday, January 21, 2019

JavaScript calculator using grid layout

Since I'm getting to grasp basics of grid layout, what project could be better than the good old calculator ?

Despite my initial thinking that it will be somehow complex to implement, it was actually pretty easy and neat, about 3 lines of code. I've learned about grid-template and grid-column shorthand, repeat function and span option on grid-column.

About JavaScript part, there is nothing too fancy, just some usual functionalities - basic arithmetic operations. Also, this is the first time that I have used eval() function, since I didn't really want to bother with regular expressions, and I think that this way the code is much neater and easier to read.

edit 30.1: changed variable name to be more readable


Github link

No comments:

Post a Comment