# Finding Pair of Sums

I want to go though an array and check if any two numbers would sum to the `target` value. Here’s my code:

``````function findPairForSum(arr, target) {
var pairSums = []
var newArr = []
for (var i = 0; i < arr.length; i++) {
if (arr[i] < target) {
newArr.push(arr[i])
}
}

// the above loop is to get rid of values that can't possibly be sumed to target (i.e. numbers larger than target)

//For the next loop, let's assume newArr[i] is 3

for (var k = 0; k < newArr.length; k++) {
var otherPair = target - newArr[i] // 6 = 9 - 3
if (newArr.includes(otherPair)) { // if newArr has 6
pairSums.push(newArr[i], otherPair) // push [3,6] to pairSum array
}
}
return pairSums
}

findPairForSum([3, 34, 4, 12, 5, 2], 9);
``````

Can anyone tell me what I did wrong? It just returns an empty array. Thanks!

You have two issues

1. You are using `i` when you mean `k`

2. You are pushing two numbers `3, 6` instead of `[3, 6]`

Also, you are getting duplicates, which you might not want.

Thanks for the answer! How do I just get one array with those numbers ([3, 6])? I tried `pairSums.push([newArr[k], otherPair])` but that didn’t work.