Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

317
Views
Given an array of integers in ascending order, check if any pair sums to 10 (using a loop only)?

input [2,3,7,9] because 3 + 7 = 10, output => true

input [4,7,9,10] output => false

input [1,2,3,5] output => false

How can I do this?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Tested with [2,3,7,9], [4,7,9,3] and [1,2,3,5]

function abc(array) {

  let output = false;

  for (let index = 0; index < array.length; index++) {
    const element = array[index];

    for (let y = 0; y < array.length; y++) {
      if (index === y) continue;
      const yElement = array[y];
      if (element + yElement === 10) {
        output = true;
        break;
      }
    }
    if (output) break;
  }
  return output;
}

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!