Assessment wanted for Arrays skill test

Link to task:

Link to the examples I would like to be assessed:
Array 1: https://codepen.io/fadildairo/pen/NWwGEWO

Array 2: https://codepen.io/fadildairo/pen/BamovyX

Array 3: https://codepen.io/fadildairo/pen/bGYVyaa

Array 4: https://codepen.io/fadildairo/pen/VwrvJWM

Hi @FadilDairo

Great job on this tasks! Here are my comments:

  • Task 1: Correct :white_check_mark:
  • Task 2: Your lastItem variable contains the last index. How could you change the code to get the last item?
  • Task 3: Correct :white_check_mark:
  • Task 4: Correct :white_check_mark: You don’t need let newArray = bird;. You could just do eBirds.push(bird);

If you like I have an additional question:
In task 4 you could also use the filter() array method instead of a for..of loop. How could this be achieved?

Have a nice day,
Michael

1 Like

Hi Michael,

I refactored the code. Kindly reassess.

1 Like

Great improvements!

In task 4 you could even shorten the line to const eBirds = birds.filter(bird => bird.startsWith('E')); because comparing a boolean value with “true” an returning the result is the same as just returning the boolean value itself.