The switch
statement in the fizzBuzz
function switches on a tuple containing two expressions—number % 3
(or “the remainder after dividing number
by three”) and number % 5
(“the remainder after dividing number
by 5”). Each case of the switch
statement compares a pattern against the output of this two-value tuple, and checks for a match.
For the number 15
, the result of (number % 3, number % 5)
is (0, 0)
—that is, the number divides exactly by both 3
and 5
. This matches the first switch
case and returns "FizzBuzz!"