Skip to content

Conversation

@mystioreo
Copy link

Random Menu Generator

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
For the places where arrays were used, could using a hash work? Could it work easily? Why or why not? Yes, a hash could technically work, but there is no benefit to using a hash here. You would have to set up hash keys for each user entry (or each pre-populated adjective, food type, etc.), and those hash keys would be arbitrary and serve no real purpose. It is easier to just used numbered indices with an array.
Did you find repetitions of the same or similar code? Why did you have to do it that way? Yes, I repeated the same code 3 times in a few instances. I wanted each array to be populated the same way by the user, so each one used the same loop of code (with array names and variables changed). Basically any time I wanted to use all 3 arrays I repeated the same code 3 times.
Did you use any loops? If so, how did it help solve a problem? Yes, my first loop(s) served to repeatedly prompt the user for input and store that input into an array. The loop is useful here because it is flexible (repeats exactly as many times as the user specifies) and concise. If I hard-coded a specific number of prompts, there would be no way to change it to accommodate more or fewer menu items. In retrospect, instead of repeating my same code three times (one for each array), it may have been better to write a loop outside the code I wanted to repeat and have it pull in a different array name and variable each time.

@mystioreo mystioreo closed this Aug 7, 2018
@mystioreo mystioreo reopened this Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant