diff --git a/src/arrayf/arrayf.ts b/src/arrayf/arrayf.ts index c53ee4696a..f6518927fd 100644 --- a/src/arrayf/arrayf.ts +++ b/src/arrayf/arrayf.ts @@ -28,5 +28,13 @@ export class arrayf { return output; } - -} \ No newline at end of file + /** + * Remove any elements that exist in the subtrahend from the minuend. + * ``` + * arrayf.subtract([1,2,3], [2,3]); // Returns [1] + * ``` + */ + static subtract(minuend: T[], subtrahend: T[]): T[] { + return minuend.filter((value) => subtrahend.indexOf(value) === -1); + } +}