Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions random_menu.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#3 arrays with different food adjectives, cooking style, and types

food_adjectives = ["hot", "soft", "small", "soggy", "watery", "crispy", "burnt", "slimey", "creamy", "greasy"]
cooking_styles = ["steamed", "grilled", "baked", "roasted", "boiled", "fried", "barbequed", "microwaved", "stir-fried", "poached"]
different_foods = ["chicken", "steak", "salmon", "dumplings", "pizza", "tacos", "sandwiches", "pasta", "cake", "tofu"]

#index so that it'll print a new number within loop
index = 1

puts "\nHere is your specialized menu.\n\n"
#running through the number of elements in food_adjectives array
10.times do
#used string interpolation to print menu
puts "#{index}. #{food_adjectives.delete_at(rand(food_adjectives.length))} #{cooking_styles.delete_at(rand(cooking_styles.length))} #{different_foods.delete_at(rand(different_foods.length))}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array.delete_at(rand(array.length)) is a clever way to solve this problem. However, this line ended up being long and difficult to read. How might you split the code up to increase readability?

index += 1
end