bashscripting-2874016 icon indicating copy to clipboard operation
bashscripting-2874016 copied to clipboard

off by one counting

Open Rumpick opened this issue 4 years ago • 0 comments

Issue Overview

Select lines won't be used in Solutions/fortune.

Description

In Solutions/fortune, you provide 4 options for $waitingnumber in the case statement, but due to $RANDOM % 3 never returning a 3, the last option will never be used.

Likewise, there are 10 options in the fortunes array but since you have 1 + $RANDOM % 10, there will never be a 0, so the first object in the array will never get used. And there is a possibility of the value of $mysterynumber being 10, which will result in no fortune at all.

I know this video will likely not be recorded, but I thought it would be beneficial to point out.

Rumpick avatar Nov 02 '21 20:11 Rumpick