Exercise 2: Nested Hash

Practice retrieving hash data stored inside another hash.

Problem statement

We have a nested hash called dictionary that contains other hashes as stored values. We also have a symbol called key. Your task is to return the keys stored in the hash that’s stored against the key.

Example

dictionary = {  :de => { :one => 'eins', :two => 'zwei', :three => 'drei' },  :en => { :one => 'one', :two => 'two', :three => 'three' },  :es => { :one => 'uno', :two => 'dos', :three => 'tres' }}

Input key = :en

Expected Output: [:one, :two, :three]

Try it yourself

Press + to interact
def return_hash(dictionary, key)
result = []
# Start your code here
return result
end