題目
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.
Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.
Here are some helpful links:
Comparison Operators
given code
function diffArray(arr1, arr2) {
var newArr = [];
// Same, same; but different.
return newArr;
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
- 遍歷arr1
- 在遍歷arr1的時候遍歷arr2。比較兩個元素是否全等颗胡。如果全等锁施,那么兩個元素的下標(biāo)都加一迷守,如果不等秧均,則把