Put every object in a specified bucket
From a short review;

You are definitely looping indeed over every entry 4 times
This belongs in a well named function
Other than that, it is very straight forward and understandable

I was thinking that people don't live all that long, you could easily build a lookup table for every possible age. This could speed this up quite a bit.
So something like this;


const dataset = [
  {name: 'Paul', age: 10},
  {name: 'Marcus', age: 5},
  {name: 'Jennifer', age: 1},
  {name: 'Linda', age: 53},
  {name: 'Mary', age: 4},
  {name: 'Rose', age: 40},
  {name: 'Peter', age: 2},
]

const buckets = [[0, 10], [10, 20], [20, 30], [30, 60]]

function createAgeBuckets(dataset, buckets){
  const start = 0, end = 1;
  const out = {}, ages = [];
  
  //Create age range
  for(const bucket of buckets){
    bucketRange = `${bucket[start]}-${bucket[end]}`;
    out[bucketRange] = {res: [], count: 0}; 
    for(let age = bucket[start]; age &lt; bucket[end];age++){
      ages[age] = out[bucketRange];
    }
  }

  //Create bucketses
  dataset.forEach(person =&gt; {
    ages[person.age].res.push(person);
    ages[person.age].count++;
  });

  return out;
}

console.log(createAgeBuckets(dataset, buckets));