makersacademy / problem-solving

For problem-solving during the PreCourse
6 stars 2 forks source link

Chapter 8 question 2 #166

Closed T-Miller0 closed 6 years ago

T-Miller0 commented 6 years ago

Hey Guys, Im not really sure where to go from here. Any ideas?

screenshot 18

afaraone commented 6 years ago

Ok, I'll give you a couple of things to help you work it out. This exercise requires two pieces of input from the user, the category name and the value. You only use gets once in line 36 for the category. Secondly, you should use indentation. Anything inbetween if and end should be indented, likewise for do and end. This will help you work out how your code is working. Finally, I think you need to try and break down the problem and simplify it. Right now, your code is assuming that the user will select "sport" as the category. As I see it the exercise wants you to do the following: The user inputs a category and a value, let's say "fruit" and "kiwi". The program should look through the people array, find the hashes where the value for the key "fruit" is equal to "kiwi". It should then print out the value for the key "name" of those relevant hashes.

T-Miller0 commented 6 years ago

screenshot 20

T-Miller0 commented 6 years ago

screenshot 21

T-Miller0 commented 6 years ago

I'm not sure why the errors are occurring

AnastasiiaBlaha commented 6 years ago

I think you’re overthinking too much. You don’t need that much. You have category and value you need to get from the user using gets.chomp which you did at the beginning. Perfect! And then you need your program to go through people array (.each) and see if the user’s input of category is equal to any user’s value in the array. When a user enters the category and then the value, the program should puts the name(s) of people who are in the same category and value.