Is there an issue with the tests?

Tell us what’s happening:

The remaining tests don’t seem to be right since I have covered the majority of the tests. Or am I wrong with the code?

Your code so far

function diffArray(arr1, arr2) {
let largeArr = arr1.length > arr2.length ? [...arr1] : [...arr2];
let smallArr = arr1.length > arr2.length ? [...arr2] : [...arr1];
let newArr = largeArr.filter((one) => !smallArr.includes(one));
return newArr;

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36.

Challenge: Diff Two Arrays

Link to the challenge:

I think that the issue is your hypothesis that the larger array will contain always all the elements in the smaller array

here, they have the same length:

[1, "calf", 3, "piglet"], [1, "calf", 3, 4] should return ["piglet", 4].

your output is missing the element in the other array

[1, "calf", 3, "piglet"], [7, "filly"] should return [1, "calf", 3, "piglet", 7, "filly"].

your output is missing the elements in the smaller array not included in the larger array

1 Like