Skip to content

Instantly share code, notes, and snippets.

@RainKolwa
Created December 11, 2019 08:03
Show Gist options
  • Save RainKolwa/926eb376b2fea7cb48b7791a668242a2 to your computer and use it in GitHub Desktop.
Save RainKolwa/926eb376b2fea7cb48b7791a668242a2 to your computer and use it in GitHub Desktop.
2019-12-11
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