Guest User

Untitled

a guest
Sep 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. def fizzbuzz(size, &strategy)
  2. arr = []
  3. (1..size).each do |num|
  4. input = num
  5. input = 'Fizz' if (num % 3).zero?
  6. input = 'Buzz' if (num % 5).zero?
  7. input = 'FizzBuzz' if (num % 15).zero?
  8. arr << input
  9. end
  10. arr.each { |item| yield item } if strategy
  11. arr
  12. end
Add Comment
Please, Sign In to add comment