Learn

You can access values in a hash just like an array.

pets = { "Stevie" => "cat", "Bowser" => "hamster", "Kevin Sorbo" => "fish" } puts pets["Stevie"] # will print "cat"
  1. In the example above, we create a hash called pets.
  2. Then we print cat by accessing the key "Stevie" in the pets hash.

Instructions

1.

Access the key-value pair you added to pets, just like step 2 in the example above.

Use puts to print that value to the console.

Folder Icon

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Already have an account?