I have an array with 101 values (representing people aged 0-100).
What would be a preferably fast and simple way of building these aggregated arrays in one go:
var input = [55,33,12 .. 98 more]
var output = {
//same as input
i1 = [],
//0-5, 6-10, 11-15 ... 96-100
i5 = [],
//0-10, 11-20, 21-30 ... 91-100
i10 = [],
//0-20, 21-40, 41-60 ... 81-100
i20 = [],
}
On a side note: Would you name these aggregate arrays by the interval ("i1", "i5") or by the number of groups/elements ("g100", "g20") - what is more intuitive if another programmers comes across these definitions?