What's missing in this code?
func([1, 2, 3, 4, 5], 6); // [ [ 2, 4 ], [ 1, 5 ] ]
func([1, 2, 3, 4], 8); // []
func([2, 4, 3, 5, 6, 1], 7); // [ [ 3, 4 ], [ 2, 5 ], [ 1, 6 ] ]
func([5, 1, 2, 8, 3], 9); // [ [ 1, 8 ] ]
func([5, 5, 5, 5], 10); // [ [ 5, 5 ], [ 5, 5 ], [ 5, 5 ] ]
function func(arr, target) {
const pairs = [];
const seen =
;
for (const num of arr) {
const other =
;
if (seen.has(other)) {
.push([
Math.min(num, other),
Math.max(num, other),
]);
}
seen.add(num);
}
return pairs;
}
Type or select from these options