Skip to content

Instantly share code, notes, and snippets.

@Vigowebs
Created February 17, 2019 07:45
Show Gist options
  • Save Vigowebs/53e377efa9e24ea476b2050b2a17da93 to your computer and use it in GitHub Desktop.
Save Vigowebs/53e377efa9e24ea476b2050b2a17da93 to your computer and use it in GitHub Desktop.
function sumFinder(arr, sum){
var len = arr.length;
for(var i =0; i<len-1; i++){
for(var j = i+1;j<len; j++){
if (arr[i] + arr[j] == sum)
return true;
}
}
return false;
}
sumFinder([6,4,3,2,1,7], 9);
// true
sumFinder([6,4,3,2,1,7], 2);
// false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment