Tell us what’s happening:
I can seem to get desired output. Someone help
Your code so far
function diffArray(arr1, arr2) {
var newArr = ;
for(let i=0;i<arr1.length;i++){
if(arr2.indexOf(arr1[i])<0){
newArr.push(arr2[i])
}
}
return newArr;
}
console.log(diffArray([1,2,3,5], [1, 2, 3, 4, 5]));
function diffArray(arr1, arr2) {
var newArr = [];
for(let i=0;i<arr1.length;i++){
if(arr2.indexOf(arr1[i])<0){
newArr.push(arr2[i])
}
}
return newArr;
}
console.log(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/81.0.4044.138 Safari/537.36
.
Challenge: Diff Two Arrays
Link to the challenge: