Spot the bug in the string map

from Hash maps
Node 24 intermediate 6 min 2 issues to find

Find the correctness bugs in this generated string map.

JavaScript
class TinyMap {
  constructor() {
    this.buckets = Array(8);
  }
  index(key) {
    return [...key].reduce((sum, char) => sum + char.codePointAt(0), 0) % 8;
  }
  set(key, value) {
    this.buckets[this.index(key)] = { key, value };
  }
  get(key) {
    const entry = this.buckets[this.index(key)];
    return entry?.value;
  }
}
Open in playground
Report an error