Created
June 3, 2016 03:17
-
-
Save jhollinger/1dc41563075129eb076bb9ce1426e95a to your computer and use it in GitHub Desktop.
This file contains 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 fizzbuzz(input) | |
input.map do |n| | |
fizz = n % 3 == 0 ? 'Fizz' : nil | |
buzz = n % 5 == 0 ? 'Buzz' : nil | |
if fizz or buzz | |
"#{fizz}#{buzz}" | |
else | |
n.to_s | |
end | |
end | |
end | |
puts fizzbuzz(1..100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment