function allTwoSum(arr,target){
let mySet=new Set();
let pairs=[];
for(let x of arr){
if(mySet.has(x)){
pairs.push([target-x,x]);
mySet.delete(target-x)
}
else{
mySet.add(target-x)
}
}
return pairs
}
console.log(allTwoSum([5,3,4,6,2],8))
console.log(allTwoSum([5,3,4,6,2,4,4],8))