Alternative challenge solution using && (You should use nested IF's)

Same concept, but instead of nesting IF statements–it uses && instead.

IMPORTANT: next lecture expands the nested IF statements for the fill fractions. My solution is a little more cumbersome to work around in the next lecture as the nested IF statement will be easier to code and follow along. But this does answer an important question some might’ve had while coding: why use nested IF statements instead of &&? The answer is in the next lecture.

If you check the comments on the next lecture, I will provide a solution that continues to use the && for the Fill Fraction part, but I’d recommend sticking with the lecture’s method.

//                  ↓↓ here
if (timerValue <= 0 && isAnsweringQuestion)
{
    timerValue = timeToReviewQuestion;
    isAnsweringQuestion = false;
}
//                       ↓↓ here
else if (timerValue <= 0 && !isAnsweringQuestion)
{
    timerValue = timeToCompleteQuestion;
    isAnsweringQuestion = true;

}

Let me know if there are any issues with this solution.

1 Like

Privacy & Terms