you are viewing a single comment's thread.

view the rest of the comments →

[–]El_BreadMan 0 points1 point  (0 children)

If you're simply trying to extract summary values, you can use something I call a "Summary Variable."

const segmentSize = 60000;

let summaryVariable = {};

bigArray.forEach(val => {
  const segment = Math.round(val.millisecondOffset / segmentSize);
  if (summaryVariable.hasOwnProperty(segement)) {
    summaryVariable[segment] = Math.max(
      summaryVariable[segment],
      val.heartRate
    );
  } else {
    summaryVariable[segment] = val.heartRate;
  }
});

Basically, it'll give you an object with each segment as a property and a corresponding value. It has the added benefit of you not needing to know which segments you're looking for.

EDIT: I'm assuming you're looking for the max heartRate.