Diff Two Arrays help

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)){
  for (var j=0;j<arr2.length;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:

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 ]

@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.::smiley:

1 Like

I got thanks for the help