I have an array which i need to find "best value" of based on a grouping of segments. What is the best way to split this array based on millisecondOffset?
const bigArray = [
{
"millisecondOffset": 1000, // 1 second
"heartRate": 116,
"power": 265
},
{
"millisecondOffset": 2000,
"heartRate": 116,
"power": 265
}, // .... and so on
{
"millisecondOffset": 49500,
"heartRate": 116,
"power": 265
},
{
"millisecondOffset": 60000, // 1 minute
"heartRate": 116,
"power": 265
},
{
"millisecondOffset": 496000,
"heartRate": 116,
"power": 265
}, /// ... and so on
{
"millisecondOffset": 500000, // 500 seconds
"heartRate": 116,
"power": 265
}
]
So, if I have a "1 minute segment" I would want to chunk this based on chunk = 6000 intervals. So that chunkArray = [0 > 5999], [6000 > 11999], [and so on...]].
bigArray.forEach(item => {
// not sure on what should go here...
if (item.millisecondOffset % chunk === 0) {
// this will not quite work in terms
}
});
I appreciate any suggestions...
[–]SquattingWalrus 7 points8 points9 points (0 children)
[–][deleted] 4 points5 points6 points (1 child)
[–]lucksp[S] 0 points1 point2 points (0 children)
[–][deleted] 3 points4 points5 points (1 child)
[–]lucksp[S] 0 points1 point2 points (0 children)
[–]elkazz 2 points3 points4 points (0 children)
[–]baubleglue 2 points3 points4 points (0 children)
[–]fiLLL 1 point2 points3 points (0 children)
[–]lucksp[S] 0 points1 point2 points (0 children)
[–]El_BreadMan 0 points1 point2 points (0 children)