-3

code to get repeating or duplicate or non unique and non repeating or non duplicate or unique in an array using javascript

dhee
  • 11
  • 1

1 Answers1

0

I think the output is coming for this code. Forgive me if I've used any unwanted things. I'm a budding developer. :)

let start = [1, 1, 2, 1, 3, 4, 5, 6, 5, 5];

let one = [];

let two = [];

let three = [];
for (let i = 0; i < start.length; i++) {
  if (!one.includes(start[i])) {
    one.push(start[i]);
  } else {
    two.push(start[i]);
  }
}

for (let j = 0; j < two.length; j++) {
  if (!three.includes(two[j])) {
    three.push(two[j]);
  }
}

console.log('Unique elements are ' + one);
console.log('Non Unique elements are ' + three);

scytale
  • 12,346
  • 3
  • 32
  • 46
dhee
  • 11
  • 1