Iterate Through All an Array items Using For Loops help

Tell us what’s happening:

All my tests in console show me as solving the test what am I doing wrong in the below code?

this is the console error code:

transformers.js:85 SyntaxError: unknown: Unexpected token (13:79)
  11 | 
  12 | // change code here to test different cases:
> 13 | console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));

Your code so far


function filteredArray(arr, elem) {
  let newArr = [];
  // change code below this line
  for (let i = 0; i < arr.length; i++) {
    if (arr[i].indexOf(elem) === -1) {
        newArr.push(arr[i]);
    }
  // change code above this line
  return newArr;
}

// change code here to test different cases:
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));

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/basic-data-structures/iterate-through-all-an-arrays-items-using-for-loops

Hi Arronk,

You are missing a closing bracket somewhere :slight_smile:

1 Like

god dam haha… typical error haha.

I actually was debugging in VS code and then copy and pasting to the chrome console to double check and did not realize my code in the fcc editor was missing it. I actually managed to fix it before your comment because I ended up just resetting all code and copy/pasting from my text editor. I’m glad I at least know now why it was throwing the error, thanks!