Open this example in the interactive library
Source code
const rows = [
{ task: "design", needs: [] },
{ task: "build", needs: ["design"] },
{ task: "test", needs: ["build"] },
{ task: "ship", needs: ["build", "test"] },
];
const result = rows
.filter(
(r) =>
!["design", "build"].includes(r.task) &&
r.needs.every((n) => ["design", "build"].includes(n)),
)
.map((r) => r.task);
console.log(JSON.stringify(result, null, 2));
Sample output
[ "test" ]
