Day 28 // 100 Days of Code
I fixed the bug! Turns out I was overcomplicating things. By a lot. I simplified the methods I used to create the random equation, and everything is running much smoother now.
For some reason, x and y would update, but the sum(x, y) function wasnāt taking the new values so it kept expecting the original answer. Iām guessing calling the function as a property of the plus object made it evaluate the sum once, and then from then on plus.function wasnt equal to the result of the function being called again, it was just equal to the result of the function being called the first time. At any rate, I understand why it was doing what it was doing, even if I donāt understand why thatās why it was doing it. (Does that make sense? I think it makes sense.)
Anyway, Iāve taken care of both that issue, and the sort issue, and I figured that one out on my own as well! It would sort 9 as being bigger than 10 because 9 is bigger than 1. I just needed to add some details to the sort function.
But seriously, this would only even come up if itās subtraction AND the numbers are 9 and 10 and what are the odds that that specific equation comes up during one of my random times testing it? I swear, I never would have caught this issue, otherwise.
I think itās just about finished as far as functionality goes. I want to add a streak counter to it, which I think will be fairly simple. And I tried ārefactoringā but honestly I donāt know where to start. I added some comments to make it all easy to understand at a glance, but Iām not sure what would be the best way to rewrite it.
So now all thatās left is the styling, and weāll be in business :D
Project you are working on: Math Game
Progress today: Fixed the bugs that I found yesterday. Added comments to the javascript, explaining what is where and why, to make it easier to understand.
Challenges you faced: Took me a minute to find the source of the bug that was wanting a wrong answer when some equations came up. It wasnāt that it was expecting a wrong answer some of the time, itās that the equations happened to match the expected answer some of the time. But the answer itself was never changing from the first one.
Tasks for tomorrow: Add the streak counter, and then work on css. Style the buttons and add some color