Skip to content

Instantly share code, notes, and snippets.

@ckaltenbach904
Created April 6, 2019 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckaltenbach904/94a9c42d828441adc0c6b9b8e1d2b8f9 to your computer and use it in GitHub Desktop.
Save ckaltenbach904/94a9c42d828441adc0c6b9b8e1d2b8f9 to your computer and use it in GitHub Desktop.
exercise 3.3
def fav_foods
# code from this method goes in here
food_array = []
3.times do
puts "Name a favorite food"#expecting input from the user and set to food_array
food_array << gets.chomp
end#end of food_array
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're doing
end#end array
end#end method
fav_foods #call the method / execute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment