const ExemCategories = [
{ ExcategoryId: 1, vSubtypeCategory: 'Police Vehicle' },
{ ExcategoryId: 2, vSubtypeCategory: 'Army Vehicle' },
{ ExcategoryId: 3, vSubtypeCategory: 'Ambulance' },
{ ExcategoryId: 4, vSubtypeCategory: 'GOV Vehicle' },
{ ExcategoryId: 5, vSubtypeCategory: 'Fire Brigade' },
{ ExcategoryId: 6, vSubtypeCategory: 'Local' }
];
const ExemKey = {
f1: "1",
f2: "2",
f3: "3",
f4: "4",
};
ExemCategories.forEach((item, index) => {
const key = `f${item.ExcategoryId}`;
const value = item.vSubtypeCategory;
ExemKey[key] = value;
});
console.log("key hh", ExemKey);
output -
key hh {
f1: 'Police Vehicle',
f2: 'Army Vehicle',
f3: 'Ambulance',
f4: 'GOV Vehicle',
f5: 'Fire Brigade',
f6: 'Local'
}

0 Comments