Skip to content

Instantly share code, notes, and snippets.

@Volizik
Created July 16, 2021 14:14
Show Gist options
  • Select an option

  • Save Volizik/8c64aaf59ff63640264a32b0163c1681 to your computer and use it in GitHub Desktop.

Select an option

Save Volizik/8c64aaf59ff63640264a32b0163c1681 to your computer and use it in GitHub Desktop.
Remove double items
function removeDouble(arr) {
const resultArray = []
for (let i = 0, length = arr.length; i < length; i++) {
const arrOfItems = arr.filter(item => item === arr[i]);
if (arrOfItems.length === 1) {
resultArray.push(arr[i])
}
}
return resultArray
}
console.log(removeDouble([1, 2, 1, 3, 3, 4, 5, 6, 4, 8, 6]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment