Ad
  • Default User Avatar

    That really helped me, Thanks!

  • Custom User Avatar

    The numbers determine which numbers in the array returned have been replaced by the words, based on divisibility. If no arguments are given, the defaults are equivalent to fizz_buzz_custom('Fizz', 'Buzz', 3, 5).

    In the examples given, fizz_buzz_custom[44] returns "FizzBuzz" because the 45th element of an array of numbers from 1 to 100 is 45, and 45 is divisible by both of the default numbers (3 and 5).

    If we pass in different arguments, for example fizz_buzz_custom("What's ", "up?", 3, 7)[2], this should return the 3rd element in the array of 1 to 100, where numbers in that array which are divisible by 3 have been replaced by "What's ", numbers in that array which are divisible by 7 are replaced by "up?", and numbers which are divisible by both are replaced with "What's up?". Since the 3rd element in an array of 1 through 100 is 3, which is divisible by 3 (the 3rd argument), this will return "What's ".

    Does that help to clarify?