Adding a variable into my function wrecks my code?

Tell us what’s happening:

Your code so far


function diffArray(arr1, arr2) {
  var newArr = [];
console.clear();
  arr2.map((x) => {
//console.clear();
let add = no;
console.log(x);

return arr1.some((y) => {
console.log(x === y);
return x === y;

});

  });
  // Same, same; but different.
  return newArr;
}

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/72.0.3626.109 Safari/537.36.

Link to the challenge:

My code worked the way it was supposed to, until I added the variable “add”. Can anyone help me understand why adding the variable breaks my code?

Thank you!

Oh! Now, I see. I should have declared add as a string. I typed no, as though it were a keyword. When I change it from no to “no”. The code works again.

1 Like