How can I add a value to an object in the array persons?
The value I want to add is lastname and variable id is the id of the object the value should be added to.
- Any help is appreciated!
const lastname = 'Jackson';
const id = 2;
const persons = [
{
id: 1
firstname: 'Mary',
lastname: 'Jackson'
},
{
id: 2
firstname: 'Ash'
}
]