Update the function fetchAndUpdateUserProfiles
that accepts two parameters, an array of user IDs and a callback function. The task is to simulate fetching user profiles with a delay of 2 seconds for each user. Once a profile is fetched, update it by adding a visited
property with a value of true
.
The fetched profiles should be simulated using a predefined array of user profiles. Each profile in the array contains a userId
, name
, email
and phone
.
After all profiles are fetched and updated, the callback function should be called with an object where the keys are the user IDs and the values are the updated profiles with all the properties or the message User not found for IDs not found in the database.
While fetching profiles, log the message Fetching profile for user ID: <userId> to the console.