Created
January 4, 2019 14:30
-
-
Save Alphabetus/564c2139292cf6c2779ea0a01a9d97e6 to your computer and use it in GitHub Desktop.
Commit for exercise 3.3
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
#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