Array.prototype.includes()
to determine values that are not part of values
.Array.prototype.filter()
to remove them.const similarity = (arr, values) => arr.filter(v => values.includes(v));
similarity([1, 2, 3], [1, 2, 4]); // [1, 2]
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️