Exercice Array Method

This is the exercice "
Using the methods you have learned, modify the xMen array already declared in the editor so that only members of the X-Men are present.

Then add all of the mutants present in the xMen array to the freelancers array."

My code:

var xMen = ['Professor X', 'Cyclops', 'Beast', 'Iron-Man', 'Hobgoblin'];
var freelancers = ['Legion', 'Magneto'];

xMen.pop ();
xMen.pop ();



for (var i = 0; i < xMen.lenght; i++)
    
    {
        freelancers.push(xMen[i]);
    }
        
console.log (freelancers); 

And im getting this error
“The for loop should iterate until the value stored in i reaches the length of the array”

And thats was the error… Thank you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.