FAQ: Iterators - The .map() Method


This community-built FAQ covers the “The .map() Method” exercise from the lesson “Iterators”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Introduction To JavaScript

FAQs on the exercise The .map() Method

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


I dont understand why they used return in the instruction but then you dont have to use it in the editor.


I have the same problem as mrooze! Also: there are no accolades in the solution, but they aren’t present in the instructions / explanations of the .map() method.


I feel like I have been thrown to the wolves ever since the course went to ‘higher order functions’ and then also in the ‘iterators’ . Just like the two previous questioners I also am stumbling over when and why to use ‘return’ and when and why to use ‘{}’ in arrow functions. I think the creators of the content know the subject so well that they believe everyone else does .

I’m also a little miffed at the fact that this forum seems not to be monitored by the course creators. There are two questions ahead of mine on the same subject since Oct 25 and no answers at Dec. 7. Are these forums only attended by struggling learners? I would expect more help out of a monthly fee.

If these lessons are building on previous lessons, I would like an easily accessible menu that would allow access to those earlier lessons so that a quick review is possible. The menu in the lower left corner only pertains to the current section. To return to previous sections I have to navigate back to the academy home then to ‘my lessons’ then go into the Javascript course to find the syllabus. I’m going to go back to the functions lesson to see if there is pertinent information I have forgotten.


Did you figure this out?


Have you had any luck with this section?


Please see this topic:

How to ask good questions (and get good answers)

providing this information means we can provide better answers

The fee is for the course content, the people helping on the forum are just volunteers (me included)

Feel free to consult external documentation, learning to read and use documentation is very valuable:


once you opened this menu, at the top of the menu should be the course name, you can click this to go syllabus overview. If you do ctrl + left mouse click, the link opens in new tab. (press ctrl + shift to go to this tab)



try this although it differs from the solution:

const secretMessage = animals.map(animals => {
return animals[0]
} )

worked for me.



try this although it differs from the solution:

const secretMessage = animals.map(animals => {
return animals[0]
} )

worked for me.


What is allowing for the elements in the ‘animals’ array to be referenced as ‘animal’?
const secretMessage = animals.map(animals => {
return animal[0]
} )
(The solution)
I don’t understand how that works. Or are JS arrays just that smart? lol


I completely agree. Ever since higher order functions this course is just lost on me.



animals =>

you define a function with a parameter animals (this should be animal):

function(animal){ /* body of function */ }

now map will call this function for every element in the array, and pass the value to animal parameter. Using the fat arrow syntax (=>) is just a shorthand for defining the function.


The .map function knows that any parameter in a function declared inside it will be the elements of the function it is being assigned to?


no, you declare the function once. Then under the hood map calls the function with a different argument (the next value of the list).

You understand the difference between function parameter and arguments?


I also agree. It’s like when they came to writing this part of the course, someone else took over and decided they just wanted to show how clever they were. I went from going through about 40% of this course pretty well, and ever since HoF and iterators I’ve totally slowed down and hit brick wall. The examples don’t help much. The thing that has helped me is keeping concise notes all the way through because as you say, navigating back is a nightmare.


And to add, the code they give in the hint looks nothing like the solution:


const bigNums = [1, 2, 3, 4, 5].map(el => el * 5);

Using a function expression in a .map() will look like:

const bigNums = [1, 2, 3, 4, 5].map(function(el){
return el * 5;


const secretMessage = animals.map(animals => {
return animals[0]
} );


Actually animal can be replaced by any other made up variable name. For example you could write:
const secretMessage = animals.map (dog => {
return dog[0];
In animals.map, animals is the true name of the array to be iterated. Any other variable name can be used as the variable name being passed in the .map function such as dog was used.


The lessons are really getting confusing since High Order Functions. Cant you try to simplify the lessons?


I found this to be the simplest syntax:

const secretMessage = animals.map(firstChar => firstChar[0]);

so the “map” iterator passes each item in the animals array to the function and saves what is returned (firstChar[0] in this case, which is the first letter of each item) in the appropriate place in the new secretMessage array.


Here is, what got me confused:

You can either write:
const secretMessage = animals.map(tier => {return tier[0]});
in this case, you use {} and return

or you can write:
const secretMessage = animals.map(tier => tier[0]);
in this case, you neither use {} nor return. If you only use return or {}, the code will not run, because it is a mixtrure of the short and the log code-version.
I still have problems with seperating this in my mind.