
const ageStructureObj = {};

for (const [ageRange, value] of Object.entries(ageStructure)) {
  const [percent, maleString, femaleString] = value.match(/([\d.]+)% \(male ([\d,]+)\/female ([\d,]+)\)/).slice(1);
  const males = maleString.replace(/,/g, '');
  const females = femaleString.replace(/,/g, '');
  ageStructureObj[ageRange] = { percent: parseFloat(percent), males, females };
}

console.log(ageStructureObj); Can we fix this code so that value.match is not a function 