I have a hash filled with 32 strings of the names and locations of NFL teams (e.g. "Baltimore Ravens", "Pittsburgh Steelers," etc.)
I'm writing a class called def search which asks the user to enter the name of a team and then runs a while loop that looks through the hash, tries to match the user inputted string with a piece of a string in the hash and return the full value.
For example, if you enter Ravens, it should return "Baltimore Ravens"
I'm not sure of the correct things to enter in my code to take the piece of the string entered and try to match it with the full string and return a result. Googling hasn't helped answer my question so I'm turning to you great people.
Thanks in advance for your help.
Real code:
def search(team, nfl)
favTeam = nfl.find_all { |i| i = team }
puts favTeam
end
That's printing all of the teams in the nfl
Array (not a Hash, I made a mistake). Not entirely sure what I'm supposed to write to make it look for team
(which is what the user has already inputted) to compare it to the values in the array.