Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGremyko Coleman
9,756 PointsI 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);
1 Answer
John Johnson
11,790 PointsThat'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?