Last active
August 31, 2016 16:35
-
-
Save chand/8f300bcba54af32bd7a0627d8493757f to your computer and use it in GitHub Desktop.
Crackle Pop! (in Ruby)
This file contains hidden or 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 cracklepop | |
array = (1..100).to_a | |
array.each do |number| | |
if number % 3 == 0 && number % 5 == 0 | |
array << "CracklePop" | |
elsif number % 3 == 0 | |
array << "Crackle" | |
elsif number % 5 == 0 | |
array << "Pop" | |
else | |
array << number | |
end | |
end | |
p array | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment