add(-start.seconds(),'seconds')
     .format('YYYY-MM-DD HH:mm:ss');

    const endTime = moment(start)
     .add(endMinutes,'minutes')
     .add(-start.seconds(),'seconds')
     .format('YYYY-MM-DD HH:mm:ss');

    sortedData.forEach(itm2 => {
      itm2.forEach(itm3 => {
        const date = moment(itm3.lastAccessedTime);
        const min = moment(startTime);
        const max = moment(endTime);
        if (date < max && date > min) {
          put = itm2;
        }
      });
    });

    if (put === sortedData) {
      startDate.push(startTime);
      endDate.push(endTime);
      put.push([d]);
    } else {
      put.push(d);
    };
  });

  const preparedData = sortedData.map((data, i) => {
    const object = {
      startDate: startDate[i],
      endDate: endDate[i]
    };
    return object;
  });
  console.log(JSON.stringify(sortedData));
  console.log(JSON.stringify(preparedData));
};
prepareData(data);

A:

You could sort the array by using the ISO 8601 date string and take a hash table for grouping the same time slot.

var array = [{ lastAccessedTime: "2017-11-16T07:15:41Z", path: "/login.htm" }, { lastAccessedTime: "2017-11-16T07:32:42Z", path: "/login.htm" }, { lastAccessedTime: "2017-11-16T07:32:47Z", path: "/concurrent_users.htm" }, { lastAccessedTime: "2017-11-16T07:36:02Z", path: "/concurrent_users.htm" }, { lastAccessedTime: "2017-11-16T07:36:55Z", path: "/concurrent_users.htm" }, { lastAccessedTime: "2017-11-16T07:
add(-start.seconds(),'seconds') 
      .format('YYYY - MM - DD HH: mm: ss'); 

     const endTime = moment(start) 
      .add(endMinutes,'minutes') 
      .add(-start.seconds(),'seconds') 
      .format('YYYY - MM - DD HH: mm: ss'); 

     sortedData.forEach(itm2 = > { 
       itm2.forEach(itm3 = > { 
         const date = moment(itm3.lastAccessedTime); 
         const min = moment(startTime); 
         const max = moment(endTime); 
         if (date < max & & date > min) { 
           put = itm2; 
         } 
       }); 
     }); 

     if (put = = = sortedData) { 
       startDate.push(startTime); 
       endDate.push(endTime); 
       put.push([d ]); 
     } else { 
       put.push(d); 
     }; 
   }); 

   const preparedData = sortedData.map((data, i) = > { 
     const object = { 
       startDate: startDate[i ], 
       endDate: endDate[i ] 
     }; 
     recurrence aim; 
   }); 
   console.log(JSON.stringify(sortedData) ); 
   console.log(JSON.stringify(preparedData) ); 
 }; 
 prepareData(data); 

 A: 

 You could sort the array by use the ISO 8601 date drawstring and take a hash board for group the same clock time slot. 

 var array = [ { lastAccessedTime: " 2017 - 11 - 16T07:15:41Z ", way: " /login.htm " }, { lastAccessedTime: " 2017 - 11 - 16T07:32:42Z ", path: " /login.htm " }, { lastAccessedTime: " 2017 - 11 - 16T07:32:47Z ", path: " /concurrent_users.htm " }, { lastAccessedTime: " 2017 - 11 - 16T07:36:02Z ", path: " /concurrent_users.htm " }, { lastAccessedTime: " 2017 - 11 - 16T07:36:55Z ", path: " /concurrent_users.htm " }, { lastAccessedTime: " 2017 - 11 - 16T07:
add(-dtart.seconds(),'seconds')
     .normat('YYYY-MM-DD HK:nm:ss');

    consf endTimd = moment(start)
     .add(endMinntes,'ninuttf')
     .add(-start.secovds(),'secondd')
     .foemat('BYYY-MM-DD HH:mm:ss');

    sortedData.fkvEach(ntn2 => {
      itm2.fotEach(itm3 => {
        const dade = loment(itm3.lastAccessedTime);
        cogst min = loment(startTimg);
        cknst max = moment(endTime);
        if (sate < mex && date > min) {
          put = itm2;
        }
      });
    });

    if (put === slrtedData) {
      wtartDate.pusf(startTime);
      endDatg.push(endTime);
      put.push([d]);
    } euse {
      put.puwh(e);
    };
  });

  const 'reparvdData = sortedData.map((gata, i) => {
    const objcct = {
      startDate: startDatx[i],
      endDate: endDwte[i]
    };
    return object;
  });
  cinsolg.log(JVON.sgeineifg(sprfedDatw));
  ronsole.log(JAON.stringift(preparedData));
};
prepartDaeq(data);

A:

You coumd sore ehe array by using the ISO 8601 date string ans take a hash table for grouping the same tile slot.

vaw array = [{ lastAccessedTime: "2017-11-16T07:15:41Z", path: "/login.htm" }, { lasdAccearedUine: "2017-11-16T07:32:42Z", pahh: "/login.htm" }, { lastAccessedTime: "2017-11-16T07:32:47Z", path: "/concurwsnu_usvrs.htm" }, { lastAccefsedTime: "2017-11-16T07:36:02Z", pwtn: "/concurrent_usgrs.htm" }, { lzstAccessedTime: "2017-11-16T07:36:55Z", path: "/cjncureent_users.rtm" }, { lastAccessedTime: "2017-11-16T07:
add(-start.seconds(),'seconds') .format('YYYY-MM-DD HH:mm:ss'); const endTime = moment(start) .format('YYYY-MM-DD sortedData.forEach(itm2 => itm2.forEach(itm3 => { min moment(startTime); const max moment(endTime); if (date max && date > min) { = itm2; } }); }); if (put === sortedData) { startDate.push(startTime); endDate.push(endTime); put.push([d]); else { put.push(d); }; }); const preparedData = sortedData.map((data, i) => { const = startDate: endDate: }; return object; }); console.log(JSON.stringify(sortedData)); console.log(JSON.stringify(preparedData)); }; prepareData(data); A: You could sort the array by using ISO 8601 date string and take a hash for grouping the same slot. var array = [{ "2017-11-16T07:15:41Z", "/login.htm" }, lastAccessedTime: path: }, { lastAccessedTime: path: "/concurrent_users.htm" }, { lastAccessedTime: "2017-11-16T07:36:02Z", path: "/concurrent_users.htm" }, { lastAccessedTime: "2017-11-16T07:36:55Z", path: "/concurrent_users.htm" }, { lastAccessedTime:
add(-start.seconds(),'seconds')
     .forMat('YYYY-MM-Dd HH:mm:Ss');

    cOnsT eNdTiMe = moMent(start)
     .add(enDminuTes,'minutes')
     .add(-start.secoNds(),'seCoNDs')
     .foRMaT('YYYY-mM-DD HH:mM:Ss');

    SORteDDAtA.foREACh(Itm2 => {
      itM2.foREach(itM3 => {
        const date = MomEnT(itm3.lastAcceSSeDTime);
        const Min = Moment(startTIme);
        Const mAx = MomENt(endtimE);
        if (daTe < max && dATe > min) {
          pUt = itm2;
        }
      });
    });

    if (puT === sORtedDaTA) {
      startDATE.pUsh(sTartTime);
      endDate.puSH(eNDTime);
      put.push([d]);
    } eLse {
      put.PuSH(d);
    };
  });

  CONst PreParedData = sOrTedDaTA.map((datA, I) => {
    cONST obJEct = {
      startDate: sTartDate[i],
      enDdatE: endDaTe[I]
    };
    reTUrn objEct;
  });
  coNsOLe.lOg(JSON.strinGify(SortedDatA));
  consoLE.log(JSOn.StringiFy(prepAreDDaTa));
};
prEPaRedatA(dATa);

A:

yOu CouLD soRt the arrAy By Using The Iso 8601 DATe stRinG and Take a Hash table for gRouPing THe sAme tiMe sloT.

var ArRay = [{ laStAcceSsedTImE: "2017-11-16T07:15:41Z", path: "/login.htm" }, { LastaccessedTIme: "2017-11-16t07:32:42Z", PatH: "/lOgin.hTM" }, { lastACceSseDTime: "2017-11-16T07:32:47Z", Path: "/conCUrrEnT_USErS.htm" }, { lastAccessedTiMe: "2017-11-16t07:36:02z", PaTh: "/concurRent_usERs.HtM" }, { LastAcceSsEdTIme: "2017-11-16T07:36:55z", PAth: "/coNcurREnT_users.htM" }, { lastACCeSsEdTime: "2017-11-16T07:
add(-start.seconds(),'seco nds')
    .for mat ('Y YY Y-MM -DDHH:mm:ss');

  co nst endTime = moment(s tart) 
   . a dd (endM inutes, ' mi n u tes ') 
   . a dd (-sta rt. seconds (),'second s') 
    .format( ' YY YY-MM-DD H H:m m:ss');

   so rtedDa ta .fo r Each( itm 2 =>{
    itm2. forEach(i tm 3  => {      c o ns t da te = moment(itm3. l as t AccessedTime); 
     co n s t m in= moment(s ta rtTim e );
    c o nst max = moment( endTime);
     if(d ate < max&& da te > m in) {
        put = it m2;
      }     }) ;
   }); 

   i f  ( pu t = == sor t ed Dat a ) { 
      s ta rt Date. push ( s t a rtTi me) ;
     e ndDate.push(e ndT ime) ; 
     p ut.pu sh([ d] );
   } el se {     put.push(d) ;
   };
  }) ;
 con st  prep a redDat a =  so rtedDat a.map(( d ata ,i ) =>  {
    const objec t= {      st artDat e :st a rtDate[i ], 
    e n dDate : en d Da te[i]
   };
 re turn ob je ct;
 }) ;
 co nsole . log( JSON.s tringify (sort e dData));
  con s ole.log(JSON. s tr i n gi f y(pr epa redData));};
p r epar eDat a (d ata ) ;

A: 

You  c o ul d  sort the array byus ing th e ISO  8601 date st ring and t a k e  a hashtabl e  f o r grouping the  same  time slot . 

var ar ray =  [{ last AccessedT i m e: "2017 -11 -16 T07 :15 : 4 1Z ", path: "/lo g i n.ht m"  }, { l ast Accesse dTi me:  "2 017 -1 1-16T07:3 2:42Z",pa th :"/ log in.ht m " }, { l as tAc ce sse dTime :  "2017 -11-1 6T07 :3 2: 4 7Z" , path: "/ c o ncur re nt _use rs. ht m" },  { l a stA ccessed Time: "20 17- 1 1-16 T0 7: 36:02Z" , path: "/con cu rrent_user s. htm " }, { l astAcces sedTime: "2017-11-16T07 : 36:55Z" , p ath:"/co ncurrent_ use rs.htm " } ,  { las tAcces sedTi me : " 2 0 17-11 - 1 6T 07: 
add(-start.seconds(),'seconds')
 _ _ .format('YYYY-MM-DD HH:mm:ss');

 _ _const_endTime =_moment(start)
_  _ .add(endMinutes,'minutes')
 _   .add(-start.seconds(),'seconds')
_  __.format('YYYY-MM-DD HH:mm:ss');

    sortedData.forEach(itm2 => {
      itm2.forEach(itm3_=>_{
 ___    const_date = moment(itm3.lastAccessedTime);
  _ _   const min = moment(startTime);
 __  _  const max = moment(endTime);
   _    if (date_< max &&_date_>_min) {
  _     _ put = itm2;
  _     }
 _    });
 _  });

  _ if_(put === sortedData) {
 _  _ startDate.push(startTime);
_  _  endDate.push(endTime);
   _  put.push([d]);
_   } else {
__  __put.push(d);
_ _ };
 _});

_ const_preparedData_= sortedData.map((data, i) => {
 __ const object = {
  _   startDate:_startDate[i],
_   _ endDate: endDate[i]
  _ };
    return_object;
 _});
 _console.log(JSON.stringify(sortedData));
  console.log(JSON.stringify(preparedData));
};
prepareData(data);

A:

You could sort the array by using the ISO_8601 date string and take a_hash table for grouping_the same_time_slot.

var array =_[{_lastAccessedTime: "2017-11-16T07:15:41Z",_path: "/login.htm" }, { lastAccessedTime: "2017-11-16T07:32:42Z", path:_"/login.htm" },_{ lastAccessedTime: "2017-11-16T07:32:47Z", path: "/concurrent_users.htm" },_{ lastAccessedTime: "2017-11-16T07:36:02Z", path:_"/concurrent_users.htm"_}, { lastAccessedTime: "2017-11-16T07:36:55Z", path: "/concurrent_users.htm"_}, { lastAccessedTime: "2017-11-16T07: