Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Commit for exercise 3.3
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
food_array.each do |food|
puts "You like #{food[:food_name]} which is #{food[:food_description]}."
# 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment