Tell us what’s happening:
So after an hour I decided to check out the solutions. I completely forgot what the meaning of
...
is and I was hoping someone could point out a link I can read because this solution makes sense, but not knowing what ...
means throws me off. I tried Googling it but couldn’t find anything. Is there a name for using ...
? Thanks.
Your code so far
function diffArray(arr1, arr2) {
var newArr = [...diff(arr1,arr2), ...diff(arr2,arr1)];
//check if element is in both arrays and remove it
function diff(x,y){
return x.filter(e => y.indexOf(e) === -1);
}
return newArr;
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
diffArray(["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays