const arr = [
{ id: 1, language: 'javascript' },
{ id: 2, language: 'node.js' },
{ id: 3, language: 'typescript' },
{ id: 4, language: 'c#' },
];
const index = arr.findIndex(object => {
return object.id === 3;
});
if (index !== -1) {
arr[index].language = 'python';
}
console.log(arr);
/*
run:
[
{ id: 1, language: 'javascript' },
{ id: 2, language: 'node.js' },
{ id: 3, language: 'python' },
{ id: 4, language: 'c#' }
]
*/