Created
February 23, 2013 00:36
-
-
Save Stephenitis/5017675 to your computer and use it in GitHub Desktop.
super fizzbuzz exercise
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 = [] #create a new array to store the results | |
#reminder to make sure that two word variables are seperated by a underscore_k? | |
array.each do |x| | |
if x % 15 == 0 | |
new_array << "FizzBuzz" #remember stephen the << is the same as saying array.push("FizzBuzz") | |
elsif x % 5 == 0 | |
new_array << "Buzz" | |
elsif x % 3 == 0 | |
new_array << "Fizz" | |
else | |
new_array << x #if it does not meet any of the if/elsif statements then the newarray is filled with original value | |
end | |
end | |
return new_array #this will return the array without displaying it | |
print new_array #this will show me my results | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment