Say I have a list [1,2,3,4,5,6,7] and I would like to find the closest sum of numbers to a given number. Sorry for the crappy explanation but here\'s an example:
Say I h
var data= [1, 2, 3,4,5,6,7]; var closest = 14; for (var x = 0; x < data.length; x++) { for (var y = x+1; y < data.length; y++) { if(data[x] + data[y] == closet){ alert(data[x].toString() + " " + data[y].toString()); } } }