Last active
December 5, 2018 04:06
-
-
Save wongjiahau/1e12a343e49be55987f75a20dc499534 to your computer and use it in GitHub Desktop.
Filter Map Reduce Exercise
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 xs = [1,2,3,4,5,6,7,8,9,10] | |
// Q1. Take only the number that is more than 5 | |
// Q2. Multiply each number by 5 | |
// Q3. Add all numbers together | |
let people = [ | |
{name: "Bob", gender: "M", age: 18, weight: 50}, | |
{name: "Ali", gender: "F", age: 15, weight: 45}, | |
{name: "Jun", gender: "F", age: 17, weight: 70}, | |
{name: "Yaa", gender: "M", age: 16, weight: 30}, | |
{name: "Wen", gender: "F", age: 12, weight: 60}, | |
] | |
// Q4. How many people are females? | |
// Q5. Give me the names of people who are heavier than 50kg | |
// Q6. What are the total age of boys? | |
// Q7. What is the average weight of girls? | |
// Q8. Give me the names of all people, for each people you have to tell me whether he/she is old | |
// A person is considered old if his/her age is more than 15 | |
// Sample answer is [{name:"Bob", old: true}, {name:"Ali", old:false} ... ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment