Check out a free preview of the full JavaScript: From Fundamentals to Functional JS, v2 course:
The "Projecting Solution" 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 walks through the solution with the help of students and takes questions from students.

Get Unlimited Access Now

Transcript from the "Projecting Solution" Lesson

[00:00:00]
>> Bianca Gandolfo: So our task was to take our filtered data and then map it into an array of strings. So right now we have an array of objects, right? Each object represents our suspects. But perhaps we really wanna simplify that. We don't really care about this other data now.

[00:00:19] We really want their names. And so we want to transform that array into an array of strings. And in these strings it should contain the names of the suspects who were present the night of the murder.
>> Bianca Gandolfo: All right, so what's the first thing we need to do?

[00:00:47]
>> Bianca Gandolfo: Anyone complete it?
>> Bianca Gandolfo: Yeah?
>> off screen: Do we have our functions from earlier?
>> Bianca Gandolfo: Yeah, so-
>> off screen: So we need a,
>> off screen: Function that will return the names.
>> Bianca Gandolfo: Yeah, so we're gonna create user map. And you're saying we need to have a function that's gonna do something with the names?

[00:01:15] Okay.
>> Bianca Gandolfo: What do we put here?
>> off screen: We need to store the return value from the filter function.
>> Bianca Gandolfo: Yeah.
>> Bianca Gandolfo: What should we call this? suspect, suspects, let's just call it. Yeah, I guess we'd call it suspects. And then this one can be suspectsName, suspects. After you look at a word for so long, you know how it starts to look weird?

[00:01:50] That's what suspects looks like to me. Okay, so now we wanna map over our suspects,
>> Bianca Gandolfo: Inside this function, and we can use arrow functions now, cuz why not?
>> Bianca Gandolfo: Actually, we can,
>> Bianca Gandolfo: Okay.
>> Bianca Gandolfo: And then what?
>> off screen: return suspects.name?
>> Bianca Gandolfo: Return suspects.name, awesome. Great, there we have it.

[00:02:30] Anyone else do it differently? Oops, I have a typo here.
>> Bianca Gandolfo: Something like that. Cool, so this is a common pattern for getting the particular data that you need. And then transforming it into some format that's relevant to whatever you're working on.