Skip to content

Instantly share code, notes, and snippets.

@shanebarringer
Created August 5, 2016 16:08
Show Gist options
  • Save shanebarringer/47d9937850bc9ff86272f2a9fb7d682c to your computer and use it in GitHub Desktop.
Save shanebarringer/47d9937850bc9ff86272f2a9fb7d682c to your computer and use it in GitHub Desktop.
let numbers = [1,2,3,4,5,6,7,8,9];
let otherNumbers = [18, 36, 4, 2, 19, 8, 7, 16, 45];
let uniqueNumbers = [];
compareArrays = (firstArray, secondArray) => {
return firstArray.forEach((number) => {
let comparison = secondArray.some((otherNumber) => {
return number === otherNumber;
});
!comparison ? uniqueNumbers.push(number) : null;
});
};
compareArrays(numbers, otherNumbers);
console.log(uniqueNumbers);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment