javascript – Associate a percentage value to each item in a data structure. The sum should be fixed

I’ve this dataset:

const data = {
  catA: {
    color: ('red', 'blue', 'yellow', 'gold'),
    animal: ('cat', 'dog', 'hamster'),
  },
  catB: {
    city: ('Syndey', 'Paris', 'Rome', 'London', 'Tokyo', 'Delhi', 'Cairo')
  }
}

and what I would like to get is a similar data structure with a percentage value assigned to each element in the arrays. The sum of the percentage values should be 100.
Some elements could have value 0 and some not, is not important how many elements have percentage 0.

Below some examples of what I’m expecting:

const res1 = {
  catA: {
    color: ('red', 0), ('blue', 10), ('yellow', 5), ('gold', 0)
    animal: ('cat', 50), ('dog', 0), ('hamster', 5),
  },
  catB: {
    city: ('Syndey', 20), ('Paris', 0), ('Rome', 0), ('London', 10), ('Tokyo', 0), ('Delhi', 0), ('Cairo', 0)
  }
}

const res2 = {
  catA: {
    color: ('red', 100), ('blue', 0), ('yellow', 0), ('gold', 0)
    animal: ('cat', 0), ('dog', 0), ('hamster', 0),
  },
  catB: {
    city: ('Syndey', 0), ('Paris', 0), ('Rome', 0), ('London', 0), ('Tokyo', 0), ('Delhi', 0), ('Cairo', 0)
  }
}

const res3 = {
  catA: {
    color: ('red', 60), ('blue', 0), ('yellow', 0), ('gold', 10)
    animal: ('cat', 5), ('dog', 5), ('hamster', 20),
  },
  catB: {
    city: ('Syndey', 5), ('Paris', 5), ('Rome', 10), ('London', 5), ('Tokyo', 0), ('Delhi', 5), ('Cairo', 10)
  }
}

So I’ve created a function that returns an array of values whose sum is fixed:

function randomNumbersWithFixedSum(quantity, sum) {
  if (quantity === 1) return (sum);
  const randomNum = _.random(0, sum);
  return (
    randomNum,
    ...randomNumbersWithFixedSum(quantity - 1, sum - randomNum),
  );
}

_.random is a Lodash function.

Now, how can I create a function that returns a result similar to the ones before?

const dataWithPercentages = addPercentages(data, 100)

function addPercentages(dataset, fixedSum) {
   const flatData = Object.values(data).flat();
   const dataCounter = flatData.length;
   const percentages = randomNumbersWithFixedSum(random(1, dataCounter), fixedSum)

   // and here?
}

I don’t know how to start. Maybe have I to use a reduce but how?