Skip to content

Instantly share code, notes, and snippets.

@sebastianherman
Created January 10, 2021 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastianherman/d12887112a10ca5ad6abbfde17104230 to your computer and use it in GitHub Desktop.
Save sebastianherman/d12887112a10ca5ad6abbfde17104230 to your computer and use it in GitHub Desktop.
Intermediate Algorithm Scripting: Sorted Union - freeCodeCamp solution
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