Last active
August 5, 2016 18:01
-
-
Save shanebarringer/9946623a24b0400b9cdfe007b7b05cf4 to your computer and use it in GitHub Desktop.
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
let numbers = [1,2,3,4,5,6,7,8,9]; | |
let otherNumbers = [18, 36, 4, 2, 19, 8, 7, 16, 45]; | |
Array.prototype.compare = (firstArray, secondArray) => { | |
let uniqueNumbers = []; | |
firstArray.forEach((number) => { | |
let comparison = secondArray.some((otherNumber) => { | |
return number === otherNumber; | |
}); | |
!comparison ? uniqueNumbers.push(number) : null; | |
}); | |
return uniqueNumbers; | |
}; | |
let foo = [].compare(numbers, otherNumbers); | |
console.log(foo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment