Created
February 17, 2019 07:45
-
-
Save Vigowebs/53e377efa9e24ea476b2050b2a17da93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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