Created
July 15, 2015 15:11
-
-
Save margieI/f1324bd7547d7ffe9d62 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 fav_foods | |
# code for this method goes in here | |
food_array = Array.new | |
3.times do | |
puts "Name a favorite food." | |
food_array << gets.chomp | |
end | |
p food_array | |
puts "Your favorite foods are #{food_array.join(", ")}" | |
food_array.each do |food| # do something to each element in food_array; that element is to be referred to as food | |
puts "I like #{food} too!" # the thing we are doing | |
end # ends the loop | |
end | |
fav_foods | |
#The above code 12,13,14 is exactly the same thing with this. | |
#food_array.each { |food| puts "I like #{food} too!" } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment