JSFiddle - React, Tailwind, and code Playground
JavaScript
const data = [{id: 1, name: "Kenneth"}, {id: 2, name: "Sigge"}];
const active = [];
console.log("init", data.length, active.length);
const move = (from, to, find) => {
from.forEach((e, i) => {
if (find(e)) {
from.splice(i,1);
to.push(e);
return;
}
})
}
move(data, active, ({ id }) => {
return id === 1
});
console.log("init", data.length, active.length);