Created
December 11, 2019 08:03
-
-
Save RainKolwa/926eb376b2fea7cb48b7791a668242a2 to your computer and use it in GitHub Desktop.
2019-12-11
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
const findPair = (arr, target) => { | |
loop1: | |
for(let i=0; i < arr.length-1; i++) { | |
loop2: | |
for(let n=i+1; n< arr.length; n++) { | |
if(arr[i] + arr[n] === target) { | |
return [i, n] | |
break loop1 | |
} | |
} | |
} | |
} | |
const result = findPair([5,7,10,22,23,24,56,90], 12) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment