Assessment wanted for Arrays 4 skill tests

Assessment wanted for Arrays 4 skill tests(https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Test_your_skills:_Arrays#arrays_4)

const birds = [ "Parrots", "Falcons", "Eagles", "Emus", "Caracaras", "Egrets" ];

// Add your code here

const indexOfEaglesItem = birds.indexOf('Eagles');
birds.splice(indexOfEaglesItem, 1);

const eBirds = [];

for(let i = 0; i <= birds.length - 1; i++) {
  console.log(birds[i].startsWith('E'));
  
  if (birds[i].startsWith('E')) {
    eBirds.push(birds[i]);
  }
}

console.log(eBirds);
// Don't edit the code below here!

section.innerHTML = ' ';

const para1 = document.createElement('p');
para1.textContent = eBirds;

section.appendChild(para1);

Great work again, @Manish_Pamnani :clap:

As an alternative you could use the filter() function:

const eBirds = birds.filter((bird) => bird.startsWith("E"));

Written with a traditional function instead of an arrow function and expanded a bit this would look like this:

function startsWithE(bird) {
  return bird.startsWith("E");
}
const eBirds = birds.filter(startsWithE);

I wish you all the best,
Michael

1 Like