Created
July 16, 2021 14:14
-
-
Save Volizik/8c64aaf59ff63640264a32b0163c1681 to your computer and use it in GitHub Desktop.
Remove double items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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