(ES6) ES6 (2016)

Reduce (RD01)

   1:  // First pass: determine basic status for each vehicle
   2:  const newStatuses = currentStateOfVehicles.reduce((acc, vehicleCurrentState) => {
   3:      const { id: vehicleId } = vehicleCurrentState;
   4:  
   5:      return [
   6:          ...acc,
   7:          {
   8:              vehicleId,
   9:              status: getEventForCurrentStateOfVehicle(vehicleCurrentState)
  10:          }
  11:      ];
  12:  }, []);





Reduce context:






ES6 context:



Comments ( )
Link to this page: http://www.vb-net.com/JavascriptES6/RD01.htm
< THANKS ME>