This course has been updated! We now recommend you take the JavaScript: From First Steps to Professional course.

Check out a free preview of the full JavaScript: From Fundamentals to Functional JS, v2 course:
The "_map() vs. _each()" Lesson is part of the full, JavaScript: From Fundamentals to Functional JS, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Bianca compares _map() and _each() functions.

Get Unlimited Access Now

Transcript from the "_map() vs. _each()" Lesson

>> So now we understand how to implement it. I couldn't find a free version of a broken pipe, of all things. So there's my stock photo. So yeah, here's our broken weapons. And we have a list of broken stuff. Cool, till we transform our list. Awesome, so, Here's our example from before, where we have our, and I do have a typo here.

[00:00:41] Okay, where were we? Okay, so we're mapping through our suspects, right? And remember before this was a suspectsList and we just had an array and then we were looping and pushing in. So now we don't have to do that. We'll just map through our suspects. And for each name, we'll create an object and it will return it and it will create a suspectsList, yeah?

[00:01:13] Anyone wanna see this in action, yeah or no? Yeah, okay. All right, Cool? So this is a more realistic application of map, right? Rather than concatenating strings, we're creating objects and returning them. And then we can each through them, and call each one. So here's another version of that, just with the each from before to compare.