The set
method now seems pretty straightforward, right?
It's the same concept with our get
method. What we're doing there is also running the passed key
through the hashStr
method, but instead of setting, we'll go to the resulting index and retrieve/return the found value.
1for (let keyVal of this._storage[idx]) {
2 if (keyVal[0] === key) {
3 return keyVal[1];
4 }
5 }