April 2018
Beginner to intermediate
426 pages
10h 19m
English
Retrieving a value from the HashTable instance is also simple. We will implement the get method for this purpose, as follows:
get(key) { const valuePair = this.table[this.hashCode(key)]; return valuePair == null ? undefined : valuePair.value;}
First, we will retrieve the position of the given key parameter using the hashCode method we created. This function will return the position of the value, and all we have to do is access this position from the table array and return its value.