Possible bug Diff Two Arrays

Possible bug Diff Two Arrays
0

#1

Tell us what’s happening:
The code written below runs in both the chrome console, and in VScode, but when I try to run in it in FCC, nothing happens. Is this a bug? or is the FCC editor just picky?

Your code so far


function diffArray(arr1, arr2) {
    for(let i=0;i<=arr2.length;i++)
    if(arr2[i] !== arr1[i]){
        return arr2[i]
    }
  }
  
  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/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays/


#2

the run button doesn’t work when there are syntax errors in the code.
I believe you need to add a semi colon after the line for return.
Also I heard (by reading on the forum) that you may need braces around your if statement too.

btw. the logic looks like it needs some work too…


#3

woops, thank you :expressionless: