Tell us what’s happening:
Describe your issue in detail here.
Good day, I’m quite confused as to why my code doesn’t work. I looked at the solutions on the page and solution one was very similar to the code. The only difference was the use of
“function OnlyInFirst (first, second){}” and variables accordingly. Im confused as to why this makes a difference and what difference it does make.
Kind regards
Your code so far
function diffArray(arr1, arr2) {
const newArr = [];
for( let i = 0; i < arr1.length; i++){
if(arr2.indexOf(arr1[i] === -1)){
newArr.push(arr1[i]);
}
}
return newArr;
}
console.log(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15
Challenge Information:
Intermediate Algorithm Scripting - Diff Two Arrays