https://github.com/jackhowa/differentiate-arrays
Return the symmetric difference of the two arrays
https://github.com/jackhowa/differentiate-arrays
Last synced: about 1 year ago
JSON representation
Return the symmetric difference of the two arrays
- Host: GitHub
- URL: https://github.com/jackhowa/differentiate-arrays
- Owner: JackHowa
- Created: 2017-08-23T21:49:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-28T15:16:48.000Z (over 8 years ago)
- Last Synced: 2025-01-21T16:44:35.704Z (over 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Differentiate Arrays
Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. In other words, return the symmetric difference of the two arrays.
## Tests
* diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]) should return an array.
* ["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"] should return ["pink wool"].
* ["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"] should return ["diorite", "pink wool"].
* ["andesite", "grass", "dirt", "dead shrub"], ["andesite", "grass", "dirt", "dead shrub"] should return [].
* [1, 2, 3, 5], [1, 2, 3, 4, 5] should return [4].
* [1, "calf", 3, "piglet"], [1, "calf", 3, 4] should return ["piglet", 4].
* [], ["snuffleupagus", "cookie monster", "elmo"] should return ["snuffleupagus", "cookie monster", "elmo"].
* [1, "calf", 3, "piglet"], [7, "filly"] should return [1, "calf", 3, "piglet", 7, "filly"].