April 2018
Beginner to intermediate
426 pages
10h 19m
English
Next, we will implement the remove method. It is very similar to the remove method from the Set class; the only difference is that we will first search for the key (instead of value), as follows:
remove(key) { if (this.hasKey(key)) { delete this.table[this.toStrFn(key)]; return true; } return false;}
Then, we will use the JavaScript delete operator to remove the key (transformed into a string) from the table object. In case we are able to remove the value from the dictionary, we will also return true, otherwise, we will return false.
Read now
Unlock full access