Last active
July 12, 2018 15:29
-
-
Save RSchneider94/a9611fe16b11c68addaa4457352cfc83 to your computer and use it in GitHub Desktop.
Favorite Foods Program Ruby
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 | |
food_array = [] | |
3.times do | |
puts 'Please, type the name of a food that you really like:' | |
usr_fav_food = gets.chomp | |
food_array.push(usr_fav_food) | |
puts "Your favorite food \"#{usr_fav_food}\" was added to the list!" | |
end | |
puts "Here is your favorite foods list: #{food_array.join(', ')}" | |
food_array.each do |food| | |
puts "I love that \"#{food}\" too!" | |
end | |
end | |
# Here is just a test of Hashes | |
my_hash = { name: 'Jhon', age: 23, favorite_foods: ['banana', 'apple', 'meat'] } | |
puts my_hash | |
# Example of a another array method | |
example_array = [2, 4, 5, 10, 20] | |
example_array.slice!(2) | |
puts example_array | |
fav_foods |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment