Last active
February 13, 2020 18:14
-
-
Save Mk-Etlinger/8ca9a893eff7c2f9667694551be51839 to your computer and use it in GitHub Desktop.
pairSum Solution
This file contains hidden or 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
| /* | |
| * 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