Despite trying countless times, I can't seem to figure out where I'm going wrong.
function userChecker(arr1,arr2) {
let map = {};
arr1.filter((user) => {
arr2.filter((obj) => {
if (user == obj.user) {
map[user] = obj;
}
else {
map['untracked'] = [user];
}
});
});
console.log(map)
}
userChecker([39471379, 44471379, 25471379, 35471379, 29471379,55471379],[{user: 39471379, salary: 250000}, {user: 44471379, salary: 260000}, {user: 35471379, salary: 148700},{user: 29471379, salary: 270500}]);
A function is needed that takes in two arrays: one containing user numbers and the other containing objects with employee data (user number and salary). The function should create an object where the user number is the key and the corresponding value is the object with all the data. // If an employee with a specific user number is not found, it means they do not work for the company. In such cases, a new entry must be created with the key being "untracked" and the value as an array of all user numbers that are not found.
Expected Output:
{39471379: {ID: 39471379, salary: 250000},
44471379: {ID: 44471379, salary: 260000},
35471379: {ID: 35471379, salary: 148700},
29471379: {ID: 29471379, salary: 270500},
"untracked": [25471379,55471379]}