That was a sidestep, but back to the calculator! I wrote it a couple different ways. Thursday night I played around with the HTML skeleton for what would be the better part of an evening. I originally went with a div table created by some table creator, then realized upon styling that the display: table attributes were really screwing with my idea of how the project would go. I couldn’t get the “display” cell to widen and also be in line (height-wise) with its neighboring cells. I ended up spending some extra time reorganizing and it took me about 2.5 minutes to get the layout perfect using just flex properties and width %’s. I was very happy I chose to go that route at the end of the day but I wish I had done that from the beginning.
While I was writing that beastly conditional, I came across a built-in called eval which does exactly that: evaluates a string as a mathematical function. The problem was this: the way I had to organize my input to get it to split left and right of the mathematical operator made it impossible to run eval on.
Which is where I decided to rewrite the function! With (only a little) help from Bubba I had this bad boy up and running in no time:
Not only does it work more effectively, it is a beautiful piece of code. The hard mode for this project was to add in a square root and modulo button, which as you can see has been done. Eval works for modulo but not for square root, as the nature of square root is a little different. I threw in a quick conditional case for that button and was done! I finished all parts of this project by Friday evening, which I was extremely proud of after how intense this past week had been. I can only hope the rest of the course treats me as kindly as the first three weeks! I’ve spent the last couple days taking care of personal things and spending a few hours a day working on supplemental exercises which I am grateful for as I feel they are solidifying the knowledge of the past weeks.
We also had a review Friday. It was brief and basic. I was told I was not a concern for the instructor since my pace was on par with the expectation and asked if I had any questions. I was hoping to get something a little more in depth than that, but for now I’ll take it. I’m meeting with the campus director tomorrow so I’ll be able to express any lingering concerns then.
Let’s see what this week has in store!