Learn

Now that we have all of the functionality of a Hash Map, it’s time to review what we’ve learned!

Instructions

1.

Create a hash map hash_map. Give it an array size over 15.

2.

Assign the following key-value pairs to hash_map:

  • Key: 'gabbro', Value: 'igneous'
  • Key: 'sandstone', Value: 'sedimentary'
  • Key: 'gneiss', Value: 'metamorphic'
3.

Retrieve the value from each of the three keys from hash_map. Print them out!

4.

Congratulations! You implemented a fully-functional hash map! Some things to consider:

  • How would you delete a key-value pair from this hash map?
  • Parts of the code are a little repetitive, how would you factor these roles differently?
  • What should your hash map do if a key-value is added and the array is full? How does this hash map handle that?

Sign up to start coding

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

Or sign up using:

Already have an account?