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
Step: 1
Heres a JavaScript program that accomplishes these three tasks javascript function findPairsarray co...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started