Last active
December 19, 2015 20:49
-
-
Save harrysboileau/6015621 to your computer and use it in GitHub Desktop.
I know this isn't correct, but it's currently as far as I've been able to get with SuperFizzBuzz. I can return 'FizzBuzz' when I have a multiple of 15, Fizz when 3, Buzz when 5, but I am stuck on how to put those values back into the array, and ultimately return that altered array. Any thoughts/direction/hint would be very appreciated, thanks!
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 super_fizzbuzz(array) | |
new_array = [] | |
array.each do |x| | |
if x % 15 == 0 | |
new_array.push('FizzBuzz') | |
elsif x % 3 == 0 | |
new_array.push('Fizz') | |
elsif x % 5 == 0 | |
new_array.push('Buzz') | |
else | |
new_array.push(x) | |
end | |
end | |
return new_array | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much Christian and Keith!That was my lingering issue. Now I've got it working....but could clearly be cleaner with a bit of refactoring....