Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed JavaScript Array Iteration Methods!
You have completed JavaScript Array Iteration Methods!
Preview
You can combine filter() and map() to clean an array of unwanted values before transforming the leftover items. Let's work with some examples in this video.
Snippets from the Video
const userNames = ['Samir', 'Angela', 'Beatrice', 'Shaniqua', 'Marvin', 'Sean'];
// Result: [{name: 'Samir'}, {name: 'Shaniqua'}, {name:'Sean'}];
const users = [
{name: 'Samir', age: 27},
{name: 'Angela', age: 33},
{name: 'Beatrice', age: 42},
{name: 'Shaniqua', age: 30},
{name: 'Marvin', age: 23},
{name: 'Sean', age: 47}
];
// Result: ['Angela', 'Beatrice', 'Shaniqua', 'Sean'];
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
the remaining elements in some way.
0:00
For example,
here's the list of names in an array.
0:01
Let's take only the ones starting with the
letter S and create an array of objects.
0:04
Each object should have one property,
0:10
name, which points to the string
value of the username's array.
0:13
Here's what we want to construct.
0:18
Since you've already seen these two
methods together, pause the video and
0:20
see if you can work out
how to create this array.
0:24
To solve this,
I first created a new variable, users.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up