Reduce data value by object property

PHOTO EMBED

Wed Jun 01 2022 14:11:06 GMT+0000 (Coordinated Universal Time)

Saved by @jen_magpantay #javascript #sass #gulp #css

const reduceData = (data: any[], property: string) => {
  const result = data.reduce((acc, amount) => {
    return acc + Number(amount[property]);
  }, 0);
  return result;
};
content_copyCOPY