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

183
Views
How can I create a function that will remove the duplicate number but also the actual number? input [1,2,2,3,3,4] output should be [1,4]

I want to remove all the duplicate numbers and the function will return a unique number that has no duplicate number. Suppose I have this array [1,2,2,3,3,4] I want to return [1,4] because 1,4 doesn't have duplicate numbers.

This is my code and the problem is I am getting duplicate numbers too. The Input of this function is [6, 1, 2, 3, 1, 2, 2, 3] and the output should be [6]

Can anyone help me with how can I solve my problem?

function deleteProducts(ids, m) {
  // Write your code here
  var uniqueArray = [];

  // Loop through array values
  for (i = 0; i < ids.length; i++) {
    if (uniqueArray.indexOf(ids[i]) === -1) {
      uniqueArray.push(ids[i]);
    }
  }
  return uniqueArray;

}

deleteProducts([6, 1, 2, 3, 1, 2, 2, 3]) // output [6, 1, 2, 3]
about 4 years ago · Juan Pablo Isaza
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!