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

164
Views
Elimine duplicados de dos matrices y muestre una de las matrices en javascript

Quiero eliminar una matriz duplicada de dos matrices, pero solo mostrar una matriz, ¿cómo puedo hacerlo? quiero resultado [1, 4]

 const arr1 = [1, 2, 3, 4]; const arr2 = [2, 3, 5, 6] function arrayUniq(arr1, arr2) { enter code here }
about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

Como dijo @Titus, simplemente filtre la matriz comparando si uno de ellos tiene valores repetidos.

 const arr1 = [1, 2, 3, 4]; const arr2 = [2, 3, 5, 6]; function arrayUniq(arr1, arr2) { const arrays = [...arr1,...arr2] return arrays.filter(a=> !arr2.includes(a)) } console.log(arrayUniq(arr1,arr2))

about 4 years ago · Santiago Gelvez Report

0

// remove duplicates from arr1 and arr2 function arrayUniq(arr1, arr2) { let result = []; // Find unique elements in arr1 & push them into result arr1.forEach((e) => (arr2.find((f) => f === e) ? null : result.push(e))); // Find unique elements in arr2 & push them into result arr2.forEach((e) => (arr1.find((f) => f === e) ? null : result.push(e))); return result; } console.log(arrayUniq(arr1, arr2));
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!