this is my array in js:
const array = [
{
id: 1,
userId: 1,
title: 'test1',
},
{
id: 2,
userId: 1,
title: 'test2',
},
{
id: 3,
userId: 1,
title: 'test3',
},
{
id: 4,
userId: 1,
title: 'test4',
}
]
and I only need to grab the object where I know its id and assign it to a variable. I know that I will need an object with id number 1 so I would like to:
const item = {
id: 1,
userId: 1,
title: 'test1',
},
array.prototype.filterdeveloper.mozilla.org/en-US/docs/Web/JavaScript/Reference/…