Not sure how do to this, so any help is greatly appreciated
Say I have :
const array1 = [1, 1, 2, 3, 4];
const array2 = [1, 2];
Desired output
const result = [1, 3, 4];
I wish to compare array1
and array2
and for each entry in array2
, remove the equivalent from array1
. So if I have 3 of 1 in array1
and 1 of 1 in array2
, the resulting array should have 2 of 1.
Working on a project that has both jquery and underscore.js if that makes anything easier.