Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Mission FizzBuzz
- def fizzbuzz(num)
- arr = [*1..num]
- arr.map! do |n|
- if (n % 15).zero? then 'FizzBuzz'
- elsif (n % 3).zero? then 'Fizz'
- elsif (n % 5).zero? then 'Buzz'
- else n
- end
- end
- arr.each { |item| yield(item) } if block_given?
- arr
- end
Add Comment
Please, Sign In to add comment