Infinite Loop in While Switch(true) CashRegister Free Code Camp
CodePen CashRegister FCC
be careful, the first comment is turned off to avoid an infinite loop, It was starting at
then I multiplied the
in the drawer thinking maybe decimal places were throwing off the conditions of the
then I was hitting the infinite loop at
and after trying to clean up the code a bit, now it occurs at
I’m testing the other commented test cases to see if and where they might encounter the same snag
Consider this: When the amount is 1, which of your cases is True?
(And the follow-up: What does this tell you about all of your cases?)
(For the sake of anyone following along that may be confused:)
checking for > meant there was no case in which the value 1 had a true case. The appropriate action is to change all cases to be >= matches (or alternatively, subtract 1 from each of the case-value numbers and retain the >).
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.