7 kyu

Coding Meetup #12 - Higher-Order Functions Series - Find GitHub admins

4,860 of 5,966PiotrBerebecki

Description:

You will be given an array of objects representing data about developers who have signed up to attend the next coding meetup that you are organising.

Given the following input array:

var list1 = [
  { firstName: 'Harry', lastName: 'K.', country: 'Brazil', continent: 'Americas', age: 22, language: 'JavaScript', githubAdmin: 'yes' },
  { firstName: 'Kseniya', lastName: 'T.', country: 'Belarus', continent: 'Europe', age: 49, language: 'Ruby', githubAdmin: 'no' },
  { firstName: 'Jing', lastName: 'X.', country: 'China', continent: 'Asia', age: 34, language: 'JavaScript', githubAdmin: 'yes' },
  { firstName: 'Piotr', lastName: 'B.', country: 'Poland', continent: 'Europe', age: 128, language: 'JavaScript', githubAdmin: 'no' }
];
list1 = [
  { 'firstName': 'Harry', 'lastName': 'K.', 'country': 'Brazil', 'continent': 'Americas', 'age': 22, 'language': 'JavaScript', 'githubAdmin': 'yes' },
  { 'firstName': 'Kseniya', 'lastName': 'T.', 'country': 'Belarus', 'continent': 'Europe', 'age': 49, 'language': 'Ruby', 'githubAdmin': 'no' },
  { 'firstName': 'Jing', 'lastName': 'X.', 'country': 'China', 'continent': 'Asia', 'age': 34, 'language': 'JavaScript', 'githubAdmin': 'yes' },
  { 'firstName': 'Piotr', 'lastName': 'B.', 'country': 'Poland', 'continent': 'Europe', 'age': 128, 'language': 'JavaScript', 'githubAdmin': 'no' }
  ]
       01  list1.
          03  ListLength      pic 9(2) value 4.
          03  dev1.
              05 FirstName    pic a(9)  value 'Harry'.
              05 LastName     pic x(2)  value 'K.'.
              05 Country      pic a(24) value 'Brazil'.
              05 Continent    pic a(8)  value 'Americas'.
              05 Age          pic 9(3)  value 22.
              05 Language     pic a(10) value 'JavaScript'.
              05 GithubAdmin  pic a(3)  value 'yes'.
          03  dev2.
              05 FirstName    pic a(9)  value 'Kseniya'.
              05 LastName     pic x(2)  value 'T.'.
              05 Country      pic a(24) value 'Belarus'.
              05 Continent    pic a(8)  value 'Europe'.
              05 Age          pic 9(3)  value 49.
              05 Language     pic a(10) value 'Ruby'.
              05 GithubAdmin  pic a(3)  value 'no'.
          03  dev3.
              05 FirstName    pic a(9)  value 'Jing'.
              05 LastName     pic x(2)  value 'X.'.
              05 Country      pic a(24) value 'China'.
              05 Continent    pic a(8)  value 'Asia'.
              05 Age          pic 9(3)  value 34.
              05 Language     pic a(10) value 'JavaScript'.
              05 GithubAdmin  pic a(3)  value 'yes'.
          03  dev4.
              05 FirstName    pic a(9)  value 'Piotr'.
              05 LastName     pic x(2)  value 'B.'.
              05 Country      pic a(24) value 'Poland'.
              05 Continent    pic a(8)  value 'Europe'.
              05 Age          pic 9(3)  value 128.
              05 Language     pic a(10) value 'JavaScript'.
              05 GithubAdmin  pic a(3)  value 'no'.

write a function that when executed as findAdmin(list1, 'JavaScript') returns only the JavaScript developers who are GitHub admins:

[
  { firstName: 'Harry', lastName: 'K.', country: 'Brazil', continent: 'Americas', age: 22, language: 'JavaScript', githubAdmin: 'yes' },
  { firstName: 'Jing', lastName: 'X.', country: 'China', continent: 'Asia', age: 34, language: 'JavaScript', githubAdmin: 'yes' }
]
[
  { 'firstName': 'Harry', 'lastName': 'K.', 'country': 'Brazil', 'continent': 'Americas', 'age': 22, 'language': 'JavaScript', 'githubAdmin': 'yes' },
  { 'firstName': 'Jing', 'lastName': 'X.', 'country': 'China', 'continent': 'Asia', 'age': 34, 'language': 'JavaScript', 'githubAdmin': 'yes' }
]
      01  result.
          03  ResLength       pic 9(2) value 2.
          03  .
              05 FirstName    pic a(9)  value 'Harry'.
              05 LastName     pic x(2)  value 'K.'.
              05 Country      pic a(24) value 'Brazil'.
              05 Continent    pic a(8)  value 'Americas'.
              05 Age          pic 9(3)  value 22.
              05 Language     pic a(10) value 'JavaScript'.
              05 GithubAdmin  pic a(4)  value 'yes'.
          03  .
              05 FirstName    pic a(9)  value 'Jing'.
              05 LastName     pic x(2)  value 'X.'.
              05 Country      pic a(24) value 'China'.
              05 Continent    pic a(8)  value 'Asia'.
              05 Age          pic 9(3)  value 34.
              05 Language     pic a(10) value 'JavaScript'.
              05 GithubAdmin  pic a(4)  value 'yes'.

Notes:

  • The original order should be preserved.
  • If there are no GitHub admin developers in a given language then return an empty array [].
  • The input array will always be valid and formatted as in the example above.
  • The strings representing whether someone is a GitHub admin will always be formatted as 'yes' and 'no' (all lower-case).
  • The strings representing a given language will always be formatted in the same way (e.g. 'JavaScript' will always be formatted with upper-case 'J' and 'S'.




This kata is part of the Coding Meetup series which includes a number of short and easy to follow katas which have been designed to allow mastering the use of higher-order functions. In JavaScript this includes methods like: forEach, filter, map, reduce, some, every, find, findIndex. Other approaches to solving the katas are of course possible.

Here is the full list of the katas in the Coding Meetup series:

Coding Meetup #1 - Higher-Order Functions Series - Count the number of JavaScript developers coming from Europe

Coding Meetup #2 - Higher-Order Functions Series - Greet developers

Coding Meetup #3 - Higher-Order Functions Series - Is Ruby coming?

Coding Meetup #4 - Higher-Order Functions Series - Find the first Python developer

Coding Meetup #5 - Higher-Order Functions Series - Prepare the count of languages

Coding Meetup #6 - Higher-Order Functions Series - Can they code in the same language?

Coding Meetup #7 - Higher-Order Functions Series - Find the most senior developer

Coding Meetup #8 - Higher-Order Functions Series - Will all continents be represented?

Coding Meetup #9 - Higher-Order Functions Series - Is the meetup age-diverse?

Coding Meetup #10 - Higher-Order Functions Series - Create usernames

Coding Meetup #11 - Higher-Order Functions Series - Find the average age

Coding Meetup #12 - Higher-Order Functions Series - Find GitHub admins

Coding Meetup #13 - Higher-Order Functions Series - Is the meetup language-diverse?

Coding Meetup #14 - Higher-Order Functions Series - Order the food

Coding Meetup #15 - Higher-Order Functions Series - Find the odd names

Coding Meetup #16 - Higher-Order Functions Series - Ask for missing details

Functional Programming
Data Structures
Arrays
Fundamentals
Algorithms
Strings

Stats:

CreatedNov 17, 2016
PublishedNov 17, 2016
Warriors Trained6762
Total Skips94
Total Code Submissions11040
Total Times Completed5966
JavaScript Completions4860
Python Completions1169
COBOL Completions6
Total Stars51
% of votes with a positive feedback rating94% of 928
Total "Very Satisfied" Votes828
Total "Somewhat Satisfied" Votes91
Total "Not Satisfied" Votes9
Total Rank Assessments8
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • PiotrBerebecki Avatar
  • user8476848 Avatar
  • albertogcmr Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • dfhwze Avatar
Ad