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.

Revisions

  1. Volizik created this gist Jul 16, 2021.
    12 changes: 12 additions & 0 deletions doubleItems.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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]))