forginater / quiz-app

0 stars 0 forks source link

Only give user n seconds to answer question #11

Open kanerogers opened 2 years ago

kanerogers commented 2 years ago

Background

Now let's make it interesting. The user has to answer the question in a limited number of seconds, or else.

TODO

Emergent Issues (Alexatron)

forginater commented 2 years ago

Update

Hey, mangosteen. I got a buggy as fuck version of issue11 implemented.... (Emergent issues) are outlined above which I'm working through atm.

Based on the specifications, there are a few ways I could implement the control flow.

Proposed Program Logic

forginater commented 2 years ago

I chose to store "timeUp" & "answerChecked" in the local variable "done" as they have the same boolean logic with respect to the quiz control flow. From what I read online, with data entirely derived from state, just store it in a local variable. I figured there are other modes and ways this could be configured where the logic of "timeUp" and "answerChecked" may diverge. Not sure if this is the best way to do things!?

You mentioned using naive solutions: So I just wrote an extra component \<CountDownFrozen> rather than passing in a onChange={doNothing} function to the preexisting \<GuessFrozen> when (done is true). Using one component for the input field and using multiple onChange() functions for different scenarios passed in through props seems more elegant and uses less lines of code but I was tired and being lazy with typescript. Lemme know if this is a bad habit to adopt though.