Skip to content

Conversation

@avalliere
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? A hash seems superfluous because I'm not sure what use key/value pairs could have been in the requirements of this program.
Did you find yourself repeating the same code? Why did you have to do it that way? I didn't find myself repeating much code except in creating multiple arrays
What type of loop did you use? Why did you choose that type? I used an each iteration on a range. I found this an easier way to print numbers 1 - 10 and my menu items from within the same code.

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

Good work overall!

# random menu generator loop numbering menu items 1 - 10 and taking a random element from descriptor, cooking_style, and foods arrays
(1..10).each {
|n| puts "#{n}. #{descriptor.sample} #{cooking_style.sample} #{food.sample}"
}
Copy link

@droberts-sea droberts-sea Feb 10, 2017

Choose a reason for hiding this comment

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

Style nitpick: we'd like to encourage you to use do...end rather than curly braces, and the iteration variable (|n|) should go on the first line (think of it like a method parameter). So this loop would be rewritten as:

(1..10).each do |n|
  puts "#{n}. #{descriptor.sample} #{cooking_style.sample} #{food.sample}"
end

BTW, using (1..10).each is a clever way to get around 10.times starting at zero. Nice work.

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