We can excess the name of employee and their salary and change their name using for loop. We use for loop for changing their name with a, b, c, d
const employeeInfo = [
{name: "Alex", location: "Chicago", salary: 8000,},
{name: "Emma", location: "New York", salary: 7500,},
{name: "Max", location: "Los Angeles", salary: 8200,},
{name: "Liam", location: "Seattle", salary: 7900,}
];
let newTable = {};
for(let index = 0 ; index < 4 ; index++) {
const employee = employeeInfo[index];
const names = ['a','b','v','d']
const currentName = names[index];
newTable[currentName] = employee.salary;
};
console.log(newTable);
Result:
0 Comments