Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Commit for exercise 3.3
#methods
def favFoods(runs)
food_array = []
runs.times do
# get info > store > hash
# get food name
puts "Name a favourite food."
f_name = gets.chomp
# food_array[:food_name] << gets.chomp
# get food description
puts "Describe this plate."
f_desc = gets.chomp
# insert in array
dataArray = {
food_name: f_name,
food_description: f_desc
}
food_array << dataArray
end
food_array.each do |food|
puts "You like #{food[:food_name]} which is #{food[:food_description]}."
end
# NOTE: Why does the statement from 22 to 24 works but not the statement on 28?
# puts "Your favourite foods are #{food_array[:food_name].join(", ")}.\n\n"
end
#execute
favFoods(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.