Question: Write a Javascript program that allows for an integer array to be passed in and will then output all of the pairs that sum up

Write a Javascript program that allows for an integer array to be passed in and will then output all of the pairs that sum up to 10. Please provide a solution that allows for 1) output all pairs (includes duplicates and the reversed ordered pairs), 2) output unique pairs only once (removes the duplicates but includes the reversed ordered pairs), and 3) output the same combo pair only once (removes the reversed ordered pairs).

An Example is shown below.

[1, 1, 2, 4, 4, 5, 5, 5, 6, 7, 9] the following results should occur:

1) output all pairs would output: [1,9], [1,9], [4,6], [4,6], [5,5], [5,5], [5,5], [5,5], [5,5], [5,5], [6,4], [6,4] [9,1] , [9,1]
2) output unique pairs only once would output: [1,9], [4,6], [5,5], [6,4], [9,1]
3) output the same combo pair only once would output: [1,9], [4,6], [5,5]

Step by Step Solution

3.39 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a JavaScript program that accomplishes these three tasks javascript function findPairsarray co... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!