tuhamworld
(Tunde Sanusi)
August 1, 2022, 12:44pm
1
Hello, Please I would like an assessment of learning about Arrays on MDN . I have completed the Assessment Test Skills here , and below are the links to my code on CodePen:
Arrays: Task 1
Arrays: Task 2
Arrays: Task 3 (I have a question about this)
Arrays: Task 4 (Something seems not to be working here too).
As for Task 3 , can you please check if I was able to get the code correctly for looping and printing the index number of an array?
For Task 4 , I use the right code which is startsWith()
but am not sure why it is showing birds.startsWith()
is not a function error
Thank you
Hello! startsWith()
method is a string method, not an array. So try this code:
const eBirds = [];
for (bird of birds){
if (bird.startsWith('E')){
eBirds.push(bird);
}
}
instead of yours:
eBirds = birds.startsWith('E',0);
Here I create new array eBirds. After that I check each birds array elements if itβs first letter is βEβ. If true then I push this element into eBirds array.
I hope this helps you with task 4.
2 Likes
tuhamworld
(Tunde Sanusi)
August 5, 2022, 3:56am
3
Thank you for sharing this.
It is quite helpful with the explanation.
I have made some changes now. Can you please recheck?
1 Like
Hello! It would be better to declare the bird variable or const inside the for loop like this:
for (const bird of birds)
instead of
for (bird of birds)
I forgot to do it in my previous answer. Sorry about that.
2 Likes
tuhamworld
(Tunde Sanusi)
August 5, 2022, 9:20am
5
Thank you for the reminder.
I just recall I ought to declare the variable as well
I have made the changes now.
Can you please check Task 3 : Assessment wanted for my Arrays skill test (Tasks 1 - 4) if I did it right