Created
September 24, 2017 15:37
-
-
Save ismaelnoble/3b9a95047ea306124ac4ba771c83f2a8 to your computer and use it in GitHub Desktop.
buzzier fizzbuzz v1.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def checkem(value) # | |
| if (value % 3).zero? && (value % 5).zero? | |
| 'FizzBuzz' | |
| elsif (value % 5).zero? | |
| 'Buzz' | |
| elsif (value % 3).zero? | |
| 'Fizz' | |
| else | |
| value | |
| end | |
| end | |
| def fizzbuzz(limit, &additionalwork) # get list and print out fizz buzzez | |
| numbers = [*1..limit] | |
| numbers.map! { |num| checkem(num) } | |
| numbers.each(&additionalwork) if additionalwork | |
| numbers | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment