Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queues - Marisol Lopez - Random Menu #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

marisol-lopez
Copy link

Random Menu

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Would a hash work just as well as an Array in this project? Why? I don't know to be honest. I think it may have been tough to pair every single string I used with a key that I had to come up with. So, I actually liked using the array because since I wanted to create a random menu generator, I didn't care about having a key value pair, I just wanted to pull randomly from a list of items.
Did you find yourself repeating the same code? Why did you have to do it that way? I don't think I found myself repeating code within the assignment. I do feel that I have used similar code to other assignments and I believe it is because repetition helps with learning and solidifying the information in our brains.
What type of loop did you use? Why did you choose that type? I used a times loop. I used it because I knew I had 10 times in each array and I used a destructive method to create a generator that would only use each item in each array only once. So, originally I had used an each loop but since I was deleting items from my array as I went, it didn't work as well to print out 10 menu items, so I went to a times loop since I knew I had a specific number of times I wanted it to run.

Copy link

@droberts-sea droberts-sea left a comment

Choose a reason for hiding this comment

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

Random Menu

What We're Looking For

Feature Feedback                                                                              
Baseline
Random Menu of 10 items displayed in the terminal. Yes
Generator pulls one random item from each array to create menu items. Yes
Readable code with consistent indentation. Yes
Extras
Menu components are not repeated Yes

Good work overall!

#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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants