The easy way to do this would be a for loop nested inside another.

But I want to solve it this way "check if the array includes both desiredSum-x and x"

```
let givenArray = [1, 2, 5, 4, 4];
let desiredSum = 7;

// nested for loop

// for (i = 0; i < givenArray.length; i++) {
//   for (j = i + 1; j < givenArray.length; j++) {
//     if (givenArray[i] + givenArray[j] == desiredSum) {
//       flag = 1;
//       console.log(givenArray[i] + " & " + givenArray[j]);
//     }
//   }
// }

// generate all possible sums from desiredSum and check if both of required numbers are available

for (i = 0; i < givenArray; i++) {
    if (givenArray.includes(i) && givenArray.includes(desiredSum-i)) {
        console.log((desiredSum-x) + ' & ' + (x))
    }
}

```