Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Primer Plus

Authors: Stephen Prata

6th Edition

978-0321776402, 0321776402

More Books

Students also viewed these Programming questions