it not working at all and it should be right.
Your code so far
[spoiler]function diffArray(arr1, arr2) {
var newArr = [];
// Same, same; but different.
for (var i = 0; i<arr1.length;i++) {
if (arr2.indexOf(arr1[i]===-1)){
newArr.push(arr1[i]);
}
}
for (var j=0;j<arr2.length;j++) {
if(arr1.indexOf(arr2[j]===-1)){
newArr.push(arr2[j]);
}
}
return newArr;
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);[/spoiler]
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0
.
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
Hmm… it’s not quite right. Close though!
Here’s the problem:
Inspect that code very carefully. Currently, it checks if the item is -1.
You need to add a console.log before your return statement. For the first test case you are returning the following array:
[ 1, 2, 3, 5, 1, 2, 3, 4, 5 ]
2 Likes
@Steffan153 Instead of giving away the answers, give clues and hints or explain what the existing code does or returns. Let the users figure out the code on their own.
1 Like
@Steffan153 Much better.:
1 Like
I got thanks for the help