Now that we have all of the functionality of a hash table, it’s time to review what we’ve learned. Use what you know about hash tables to record animal sounds.



Create a HashTable instance, animalSoundsHashTable. We’ll use the hash table data to store animal sounds. Give it an array size of 15.


Assign the following key-values pairs to animalSoundsHashTable:

  • Key: “Dog”, Value: “Bark”
  • Key: “Cat”, Value: “Meow”
  • Key: “Lion”, Value: “Roar”

Retrieve the location for each of the sounds in animalSoundsHashTable and print them to the terminal.


Congratulations, you implemented a fully-functional hash table! Some things to consider:

Are there any other ways of handling collisions besides separate chaining? What would be the advantages or disadvantages of a method of avoiding separate chaining? What are some disadvantages to using hash tables?

Take this course for free

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?