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

155
Views
how to combine two numbers between an array of numbers with javascript?

I have an array of numbers and would like to generate all possible combinations with 2 numbers as shown in the expected

const numbers = [1,2,3];

Expected:

const result = [
  [1,2],
  [1,3],
  [2,1],
  [2,3],
  [3,1],
  [3,2]
]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

let num = [1,2,3];
let arr = [];

for(let i=0; i<num.length; i++){

  for(let j=0; j<num.length; j++){
    if(j === i) continue;
    arr.push([num[i], num[j]]);
  }

}

console.log(arr);

about 4 years ago · Juan Pablo Isaza 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!