Guest User

Untitled

a guest
Sep 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. ## Mission FizzBuzz
  2. def fizzbuzz(num)
  3. arr = [*1..num]
  4. arr.map! do |n|
  5. if (n % 15).zero? then 'FizzBuzz'
  6. elsif (n % 3).zero? then 'Fizz'
  7. elsif (n % 5).zero? then 'Buzz'
  8. else n
  9. end
  10. end
  11. arr.each { |item| yield(item) } if block_given?
  12. arr
  13. end
Add Comment
Please, Sign In to add comment