I'm building an app in react native and I want a way in which I can regularly add a field to one ore all of the user data before pushing it to the database, It is an array of objects and I know the index of each object. I'm aware of object destructuring but I don't know how to go about this. In the example below, how do I add the field "hobby" and a value of "Football" to smith alone? Thanks in advance.
const [usersData, setUsersData] = useState([
{
name: "Jane",
sex: "female",
age: "20",
},
{
name: "Doe",
sex: "male",
age: "29",
},
{
name: "Smith",
sex: "male",
age: "24",
},
]);
const addHobby = (index, hobby) => {
//Adding the field here//
};