Created
May 8, 2017 17:58
-
-
Save mluis/5ea8b179e761431a69548627e840d610 to your computer and use it in GitHub Desktop.
You have an array of objects in JS, each containing a name, age and gender. Write a function which returns all males between 30 and 40 years old.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let f = (...args) => args[0].filter(p => p.gender == "male" && p.age > 30 && p.age < 40) | |
/* | |
Example: | |
const ppl = [ {"name":"Dr David Darmanin","age": 31, "gender": "male"}, | |
{"name":"Diana De Jesus","age": 32, "gender": "female"}, | |
{"name":"Marc von Brockdorff ","age": 33, "gender": "male"}, | |
{"name":"Christian Nussbaumer ","age": 29, "gender": "male"}, | |
{"name":"Erik Näslund","age": 35, "gender": "male"}, | |
{"name":"Shira Harash","age": 41, "gender": "female"}, | |
{"name":"Paul Kirby","age": 41, "gender": "male"}, | |
]; | |
console.log(f(ppl)); | |
*/ | |
// http://hotjar.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment