Skip to content

Commit 5b3de38

Browse files
committed
Update hash table methods.
1 parent ecd8d22 commit 5b3de38

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/data-structures/hash-table/HashTable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default class HashTable {
7878
const bucketLinkedList = this.buckets[this.hash(key)];
7979
const node = bucketLinkedList.find({ callback: nodeValue => nodeValue.key === key });
8080

81-
return node ? node.value.value : null;
81+
return node ? node.value.value : undefined;
8282
}
8383

8484
/**

src/data-structures/hash-table/__test__/HashTable.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ describe('HashTable', () => {
4343

4444
expect(hashTable.get('a')).toBe('sky');
4545
expect(hashTable.get('d')).toBe('ocean');
46+
expect(hashTable.get('x')).not.toBeDefined();
4647

4748
hashTable.delete('a');
4849

4950
expect(hashTable.delete('not-existing')).toBeNull();
5051

51-
expect(hashTable.get('a')).toBeNull();
52+
expect(hashTable.get('a')).not.toBeDefined();
5253
expect(hashTable.get('d')).toBe('ocean');
5354

5455
hashTable.set('d', 'ocean-new');

0 commit comments

Comments
 (0)