Created
March 12, 2018 22:06
-
-
Save kigiri/3fef39fc627e72620c155e02e2e85c3f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const wilder = { | |
| firstName: 'Clément', | |
| lastName: 'Denis', | |
| age: 30, | |
| isExperienced: true, | |
| } | |
| const showWilder = (w) => { | |
| const firstName = w.firstName.toLowerCase() | |
| const lastName = w.lastName.toUpperCase() | |
| return `${firstName} ${lastName} ${w.age}` | |
| } | |
| const wilderSaruman = { | |
| firstName: 'Saruman', | |
| lastName: 'Pat', | |
| age: 89, | |
| isExperienced: true, | |
| } | |
| const wilderList = [ | |
| wilder, | |
| wilderSaruman, | |
| { | |
| firstName: 'Pépito', | |
| lastName: 'Rodrigez', | |
| age: 12, | |
| isExperienced: false, | |
| }, | |
| ] | |
| const showAllWilders = list => list.forEach(showWilder) | |
| const wildersAverageAge = list => { | |
| let total = 0 | |
| list.forEach(w => total = total + w.age) | |
| return total / list.length | |
| } | |
| const over30 = list => { | |
| const filteredList = [] | |
| list.forEach(w => { | |
| if (w.age > 30) { | |
| filteredList.push(w) | |
| } | |
| }) | |
| return filteredList | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment