uniteUnique broken

Tell us what’s happening:
My code is not working and I can’t figure out why.

Basically whan my code does is:
-The first for loop iterates through the different arrays passed as arguments.
-The second for loop iterates through each element of each of the arrays passed as arguments, and pushes the element into a new array (finalArr) if the element is not found in that array.

I tried debugging and as far as I can tell, my code is not running any of the for loops and can’t figure out why. Maybe someone can help?

Your code so far


function uniteUnique(arr) {
let finalArr = [];

for (let i = 0; i < arguments.lenght; i++){
  for (let j = 0; j < arguments[i].length; j++){
    if (finalArr.indexOf(arguments[i][j]) < 0){
      finalArr.push(arguments[i][j])
    }
  }
}

return(finalArr);
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Challenge: Sorted Union

Link to the challenge:

Hello there,

Your bug is here:

for (let i = 0; i < arguments.lenght; i++){

Hope this helps

1 Like

Already found the typo! Thank you!