class todoMap {
  constructor() {
    this.map = new Map();
  }

  get(key) {
    const curVal = this.map.get(key);
    if (curVal) {
      return curVal;
    } else {
      return 'key does not exist';
    }
  }

  set(key, value) {
    const curVal = this.map.get(key);
    if (curVal) {
      this.map.set(key, [...curVal, value]);
    } else {
      this.map.set(key, [value]);
    }
  }

  transfer(from, to, num) {
    const fromVal = this.map.get(from);
    const toVal = this.map.get(to);

    if (fromVal && toVal) {
      if (num === 'all') {
        this.map.set(to, [...toVal, ...fromVal]);
        this.map.set(from, []);
      } else if (num >= 0 && num < fromVal.length) {
        const todo = fromVal.splice(num, 1)[0];
        this.map.set(to, [...toVal, todo]);
      } else {
        return 'enter a valid index';
      }

    } else {
      return 'enter valid names';
    }
  }

  delete(key, index) {
    let curVal = this.map.get(key);
    if (curVal && (index >= 0 && index < curVal.length)) {
      curVal.splice(index, 1);
      this.map.set(key, curVal);
    } else {
      return 'enter name and valid index';
    }
  }

  deleteName(key) {
    const present = this.map.has(key);
    if (present) {
      this.map.delete(key);
    } else {
      return 'key does not exist';
    }
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.