Skip to content

Instantly share code, notes, and snippets.

@huezoaa
Last active August 29, 2015 14:13
Show Gist options
  • Save huezoaa/2a3ac9126feeaff33894 to your computer and use it in GitHub Desktop.
Save huezoaa/2a3ac9126feeaff33894 to your computer and use it in GitHub Desktop.
Happy New Year Countdown
# Homework assignment. Ruby Methods 2.
# Question #1
def countdown(n=10)
(0..n).each { |count|
p (n-count) != 0 ? "#{n-count}" : "Happy New Year!"
# Because .each returns an array that can't be indexed,
# p will print each element as it gets created
# by the loop. But "print" waits unitl the array is complete to spit it out!
sleep 1
}
# puts "Happy New Year!"
end
(1995..2005).each { countdown() }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment