I'm currently working on a Homework assignment that involves passing a parameter called userID to an arrow function. Within this function, the task is to use the .find method on an array named users. This find function should retrieve an object containing the specified userID. Here are the detailed instructions:
Above the displaySelectedUser function, create an getSelectedUser arrow function. It should accept a parameter called userId and utilize the Array .find method on the users collection to locate and return the selected user object. Your .find call should employ an inline arrow function and destructure its parameter to access the id property.
The users array is as follows: users =
[{
age: 50,
weight: 55,
height: 6,
country: 'US',
name: 'Bob Manuel',
id: 'ehriuiuye'
},
{
age: 20,
weight: 80,
height: 6,
country: 'UK',
name: 'Michael Lawrence',
id: 'fjikijd'
}];
My Attempt:
const getSelectedUser = (userId) =>{
users.find(element => element.id === userId);
};
However, upon using the auto-grader tool, I encountered the following error:
Create a "getSelectedUser" function that returns the selected "user object". Refer to the instructions for further details.
Could someone please help me identify any issues with the function I have implemented?