I have this Homework that requires me to pass a parameter called userID to an arrow function. Inside this function, I am required to use the .find function on an array called users. this find function should return an object containing the userID. Here is the full instruction :
Create a getSelectedUser arrow function above displaySelectedUser. It should take a userId parameter and use the Array .find function on the users collection to find and return the selected user object. Your .find call should take an inline arrow function and de-structure its parameter to obtain the id property.
the users is an array: 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'
}];
what I have done
const getSelectedUser = (userId) =>{
users.find(element => element.id === userId);
};
Now, the auto-grader returns this error:
Create a "getSelectedUser" function that returns the selected "user object". See the instructions for details.
Is there anything wrong with the function I created?
===)