Created
January 10, 2021 14:15
-
-
Save sebastianherman/d12887112a10ca5ad6abbfde17104230 to your computer and use it in GitHub Desktop.
Intermediate Algorithm Scripting: Sorted Union - freeCodeCamp solution
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 uniteUnique(arr) { | |
let newArr = []; | |
for (let i=0; i<arguments.length; i++) { | |
for (let j=0; j<arguments[i].length; j++) { | |
if (!newArr.includes(arguments[i][j])) { | |
newArr.push(arguments[i][j]); | |
} | |
} | |
} | |
console.log(newArr); | |
return newArr; | |
} | |
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