Skip to content

Instantly share code, notes, and snippets.

@RSchneider94
Last active July 12, 2018 15:29
Show Gist options
  • Save RSchneider94/a9611fe16b11c68addaa4457352cfc83 to your computer and use it in GitHub Desktop.
Save RSchneider94/a9611fe16b11c68addaa4457352cfc83 to your computer and use it in GitHub Desktop.
Favorite Foods Program Ruby
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