Created
August 5, 2016 16:08
-
-
Save shanebarringer/47d9937850bc9ff86272f2a9fb7d682c 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]; | |
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