From the course: JavaScript: Arrays
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Advanced methods 1 - JavaScript Tutorial
From the course: JavaScript: Arrays
Solution: Advanced methods 1
(upbeat music) - [Narrator] In this challenge, we've been given an array of applicants. Each item in this array is an object with a name and an age. And in order to find our solution, we're looking to return an array that has filtered only those applicants who are 18 years or older. So for this particular challenge, we're going to use the array method filter, and filter is actually one of my favorite array methods, as strange as it may sound, but I think it's really powerful and it's really been helpful for me. So the first thing I'm going to do is just write my return statement. We don't need to, you could set a new variable and create your new array that way. I just prefer for simplicity sake to just go ahead and return what we will transform here. So we'll start with our applicants, our existing array. And remember, when we apply filter, it's going to return a new array that fits the criteria that we provide. So we'll say applicants filter, and then I'm just going to call this app…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.