loading...

re: Daily Coding Problem #1 VIEW POST

FULL DISCUSSION
 

JavaScript:
returning all possible matches:

function Problem01(arr, sum) {
  const hashTable = {};
  const res = [];

  arr.forEach(n => 
              !hashTable[n]
                ? hashTable[sum - n] = n
                : res.push([n, hashTable[n]])
             );

  return res;
}
Code of Conduct Report abuse