code: function toMap(arr, fn) {
    var obj = {};
    var i, elem;
    for (i = 0; i < arr.length; i++) {
      elem = arr[i];
      obj[fn(elem)] = elem;
    }
    return obj;
  }
docs: Convert array to map.
  
  @param arr {Array} Elements.
  @param fn {Function} Function returning an element's key.