The subject of the title may cause confusion, so let me clarify my goal.
With values of n = 51
and m = 24
, I aim to achieve this result:
[
{start:0, end:24},
{start:24, end:48},
{start:48, end:51}
]
Currently, I have made progress on this task, but I am encountering issues with adjusting the j
and end
parameters.
var n = 51;
var m = 24;
var arr = [];
for (var j = 0; j < n; j += m) {
var end = (j + j) >= n ? n : j;
console.log(j, end);
if (j > 0) arr.push({
start: j,
end: end
});
}
Any suggestions or solutions would be greatly appreciated!