Tell us what’s happening:
So I’m curious as to why this little snippet of code doesn’t work in the freeCodeCamp editor, however it functions properly in any other console I’ve tried to use? Any ideas? (The error messages don’t make much sense to me).
Thanks!!
Your code so far
function diffArray(arr1, arr2) {
var newArr = [];
// Same, same; but different.
function getValues(arr1,arr2){
var i = 0;
while (arr1.length > i || arr2.length > i){
if(arr1.includes(arr2[i]) === false){
newArr.push(arr2[i]);
}
if (arr2.includes(arr1[i]) === false){
newArr.push(arr1[i]);
}
i++;
}
console.log(newArr.filter(Boolean));
return newArr.filter(Boolean);
}
getValues(arr1,arr2);
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays