Trying to figure out the proper syntax on filtering elements out of one array if they belong in another but can't get it right. In the following example I'm trying to remove any elements in array1 that are in array2. Any ideas on how to make it work?
array1.filter( element => array2.includes( element ) );
CodePudding user response:
array1.filter( element => !array2.includes( element ) );