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));
console.log(newArr);
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: