function crateEmployeeGroupByDname(records, property) {
  // groupResult: Initial State {}
  // record: The current record to be read
  var result = records.reduce(function (groupResult, record) {
    console.log("Current State ".concat(JSON.stringify(groupResult), " and current record ").concat(JSON.stringify(record))); // read the key on which the group will be created on the current record

    var key = record[property]; // currentRecord[dname] this will be value of the property for the record
    // key will be D1, D2, D3

    console.log("Key of the record = ".concat(key)); // match each record with the previous record key in the groupResult state
    // because groupResult has the resultant records

    if (!groupResult[key]) {
      groupResult[key] = []; // if the match does not found based on key makes the resultant as empty
    } // if found then add the matched record in the resultant state


    groupResult[key].push(record);
    console.log("After match found for push state is = ".concat(JSON.stringify(groupResult))); // return the final group state

    return groupResult;
  }, {});
  return result;
}
// property: The name of the property based on which group will be created  
The name of the property based on which group will be created
The name of the property based on which group will be created
function crateEmployeeGroupByDname(records, property) {
  var result = records.reduce(function (groupResult, record) {
    console.log("Current State ".concat(JSON.stringify(groupResult), " and current record ").concat(JSON.stringify(record))); 
    var key = record[property]; 
    console.log("Key of the record = ".concat(key)); 
    if (!groupResult[key]) {
      groupResult[key] = []; 
    } 
    groupResult[key].push(record);
    console.log("After match found for push state is = ".concat(JSON.stringify(groupResult))); 
    return groupResult;
  }, {});
  return result;
}
function crateEmployeeGroupByDname ( records , property ) { var result = records . reduce ( function ( groupResult , record ) { console . log ( "Current State " . concat ( JSON . stringify ( groupResult ) , " and current record " ) . concat ( JSON . stringify ( record ) ) ) ; var key = record [ property ] ; console . log ( "Key of the record = " . concat ( key ) ) ; if ( ! groupResult [ key ] ) { groupResult [ key ] = [ ] ; } groupResult [ key ] . push ( record ) ; console . log ( "After match found for push state is = " . concat ( JSON . stringify ( groupResult ) ) ) ; return groupResult ; } , { } ) ; return result ; }
property: The name of the property based on which group will be created
property : The name of the property based on which group will be created
// groupResult: Initial State {} // record: The current record to be read // read the key on which the group will be created on the current record // currentRecord[dname] this will be value of the property for the record // key will be D1, D2, D3 // match each record with the previous record key in the groupResult state // because groupResult has the resultant records // if the match does not found based on key makes the resultant as empty // if found then add the matched record in the resultant state // return the final group state