Created
October 1, 2018 18:47
-
-
Save jepras/673ed3ce234b139b6883fd2711b80289 to your computer and use it in GitHub Desktop.
Using flat() to flatten from multiple arrays into 1. Using Set on flat array to only get unique values.
This file contains 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 uniteUnique(arr) { | |
var newArray = []; | |
for (let array of arguments) { | |
newArray.push(array); | |
} | |
var flatArray = newArray.flat() | |
var unique = [...new Set(flatArray)]; | |
return unique; | |
} | |
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment