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

Gremyko Coleman
Gremyko Coleman
8,675 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); 
                                 }//if

                       });

console.log(output);
John Johnson
John Johnson
11,481 Points

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?