function sum_pairs1(arr, sum){
for(var i=1; i<arr.length;i++){
for(var n=0;n<i;n++){
if(arr[n]+arr[i]===sum) return [arr[n], arr[i]];
}
}
}
var sum_pairs2=function(ints, s){
var x, y;
var end = ints.length;
for (var j = 0; j < end; j++) {
var t = s - ints[j];
for (var i = j + 1; i < end; i++) {
if (t == ints[i]) {
x = j;
y = i;
end = i;
}
}
}
return x == undefined ? x : [ints[x], ints[y]];
}
var a = [...new Array(50000).fill(0).map(_ => Math.round(Math.random()*8)), 14, 16];
var a1 = a.slice();
var a2 = a.slice();
console.time('1');
console.log(sum_pairs1(a1,30))
console.timeEnd('1');
console.time('2');
console.log(sum_pairs2(a2,30))
console.timeEnd('2');