I'm trying to remove one or few objects from array. Which meet the condition completed === true. Array can dynamically contain more or less objects.
const array = [{
completed: false,
id: 1595572089666,
title: "1"
},
{
completed: false,
id: 1595572089666,
title: "2"
},
{
completed: true,
id: 1595572089666,
title: "3"
},
{
completed: true,
id: 1595572089666,
title: "4"
},
{
completed: false,
id: 1595572089666,
title: "5"
}
];
function removeCompleted(arr) {
arr.reduce(item => {
return item.completed === true ? item.splice(1, 1) : false;
});
}