From 0a0cbead581f3272ca44b725cd04089da69bd717 Mon Sep 17 00:00:00 2001 From: Andree Amaro Gonzalez Date: Fri, 3 Jan 2020 03:18:40 -0700 Subject: [PATCH] fix(learn): Fixed tests for the create a hash table challenge (#37870) * fix: update create hash table's tests * fix: update the way lookup method is declared to enable the use of this.collection in it --- .../data-structures/create-a-hash-table.english.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-hash-table.english.md b/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-hash-table.english.md index d2259e7ac4..2f253d96a0 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-hash-table.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-hash-table.english.md @@ -34,7 +34,7 @@ tests: - text: The add method should add key value pairs and the lookup method should return the values associated with a given key. testString: assert((function() { var test = false; if (typeof HashTable !== 'undefined') { test = new HashTable() }; test.add('key', 'value'); return (test.lookup('key') === 'value')})()); - text: The remove method should accept a key as input and should remove the associated key value pair. - testString: assert((function() { var test = false; if (typeof HashTable !== 'undefined') { test = new HashTable() }; test.add('key', 'value'); test.remove('key'); return (test.lookup('key') === null)})()); + testString: assert((function(){ var test = false; if (typeof HashTable !== 'undefined') { test = new HashTable() }; test.add('key', 'value'); test.remove('key'); test.lookup = function(key){ var theHash = hash(key); if (this.collection.hasOwnProperty(theHash)[key]) { return this.collection[theHash][key]; } return null }; var lookup = test.lookup('key'); test.lookup = null; return (lookup === null)})()); - text: Items should be added using the hash function. testString: assert((function() { var test = false; if (typeof HashTable !== 'undefined') { test = new HashTable() }; called = 0; test.add('key1','value1'); test.add('key2','value2'); test.add('key3','value3'); return (called >= 3 && called % 3 === 0)})()); - text: The hash table should handle collisions.