Skip to content

Instantly share code, notes, and snippets.

@Mk-Etlinger
Last active February 13, 2020 18:14
Show Gist options
  • Select an option

  • Save Mk-Etlinger/8ca9a893eff7c2f9667694551be51839 to your computer and use it in GitHub Desktop.

Select an option

Save Mk-Etlinger/8ca9a893eff7c2f9667694551be51839 to your computer and use it in GitHub Desktop.
pairSum Solution
/*
* Complete the 'pairSum' function below.
*
* The function is expected to return a BOOLEAN.
* The function accepts following parameters:
* 1. INTEGER_ARRAY array
* 2. INTEGER target
*/
function pairSum(array, target) {
for(let i = 0; i < array.length; i++) {
for(let j = 0; j < array.length; j++) {
const currentNumber = array[i];
if (j !== i) {
const sum = currentNumber + array[j];
if (sum === target) {
return true;
}
}
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment