Devlog #3
Found and fixed the issue with this problem!! When b is the unknown, there are actually two possible x values (+ and -). The code was only listing ONE possible x value, and by extension, respectively, only one possible y value, as the solution. So when trying to input a solution, there was a 50/50 chance that I would put in a correct solution that was not recognized by the program.
To fix this, I’ve replaced the single number variable “solution” with a number array “solutions”, and now push each solution (even if just one) to the array; with that, I changed the checkAnswer() function from a one-time comparison to a for-of loop to iterate through all possible solutions and see if the user-provided answer is equivalent to any one.
If the randint() function has selected “b” to be the unknown:
- If the question requires x as the solution, I make the solutions ±x
- If the question requires y as the solution, I calculate two different y values with ±x
This question type is now working. Time to move on to a different one!!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.