Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Array Iteration Methods Combining Array Methods Combining filter() and map()

Gremyko Coleman
Gremyko Coleman
9,265 Points

I did my solution a different way, but had the same results

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}

const output = [];

const thirtyUsers = users.filter((user)=>{
                                 if(user.age >= 30){
                                        let userOlder = `${user.name}`;
                                           return   output.push(userOlder); 



1 Answer

That's pretty common. There's almost always more than one way to program something. The purpose of this challenge was to practice using .filter() and .map(), but that doesn't mean it's the only, or even the best, way of solving the problem.

Something good to always be thinking about: what's aspect of your code is most important to you? Readability? Conciseness? Performance? If you're programming for your employer, what standards are they looking for in code?