6 kyu

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

2,510 of 2,511PiotrBerebecki

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: null, lastName: 'I.', country: 'Argentina', continent: 'Americas', age: 35, language: 'Java' },
  { firstName: 'Lukas', lastName: 'X.', country: 'Croatia', continent: 'Europe', age: 35, language: null },
  { firstName: 'Madison', lastName: 'U.', country: 'United States', continent: 'Americas', age: 32, language: 'Ruby' } 
];
       01  List.
          03  ListLength      pic 9(2) value 3.
          03  dev1.
              05 FirstName    pic a(9).
              05 LastName     pic x(2)  value 'I.'.
              05 Country      pic a(24) value 'Argentina'.
              05 Continent    pic a(8)  value 'Americas'.
              05 Age          pic 9(3)  value 35.
              05 Language     pic a(10) value 'Java'.
          03  dev2.
              05 FirstName    pic a(9)  value 'Lukas'.
              05 LastName     pic x(2)  value 'X.'.
              05 Country      pic a(24) value 'Croatia'.
              05 Continent    pic a(8)  value 'Europe'.
              05 Age          pic 9(3)  value 35.
              05 Language     pic a(10).
          03  dev3.
              05 FirstName    pic a(9)  value 'Madison'.
              05 LastName     pic x(2)  value 'U.'.
              05 Country      pic a(24) 
                              value 'United States of America'.
              05 Continent    pic a(8)  value 'Americas'.
              05 Age          pic 9(3)  value 32.
              05 Language     pic a(10) value 'Ruby'.

write a function that

  1. adds the question property to each object in the input array where the developer has not provided the relevant details (marked with a null value in JavaScript, with the default value in COBOL). The value of the question property should be the following string:

Hi, could you please provide your <property name>.

  1. and returns only the developers with missing details:
[
  { firstName: null, lastName: 'I.', country: 'Argentina', continent: 'Americas', age: 35, language: 'Java', 
  question: 'Hi, could you please provide your firstName.' },
  { firstName: 'Lukas', lastName: 'X.', country: 'Croatia', continent: 'Europe', age: 35, language: null, 
  question: 'Hi, could you please provide your language.' }
]
       01  result.
          03  ResLength       pic 9(2) value 2.
          03  .
              05 FirstName    pic a(9).
              05 LastName     pic x(2)  value 'I.'.
              05 Country      pic a(24) value 'Argentina'.
              05 Continent    pic a(8)  value 'Americas'.
              05 Age          pic 9(3)  value 35.
              05 Language     pic a(10) value 'Java'.
              05 Question     pic x(43) 
                 value 'Hi, could you please provide your FirstName.'.
          03  .
              05 FirstName    pic a(9)  value 'Lukas'.
              05 LastName     pic x(2)  value 'X.'.
              05 Country      pic a(24) value 'Croatia'.
              05 Continent    pic a(8)  value 'Europe'.
              05 Age          pic 9(3)  value 35.
              05 Language     pic x(10).
              05 Question     pic x(44) 
                 value 'Hi, could you please provide your Language.'.

Notes:

  • At most only one of the values will be null / empty.
  • Preserve the order of the original list.
  • Return an empty array [] if there is no developer with missing details.
  • The input array will always be valid and formatted as in the example above.




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

Coding Meetup #17 - Higher-Order Functions Series - Sort by programming language

Functional Programming
Data Structures
Arrays
Fundamentals
Algorithms
Strings

Stats:

CreatedNov 29, 2016
PublishedNov 29, 2016
Warriors Trained3397
Total Skips42
Total Code Submissions8986
Total Times Completed2511
JavaScript Completions2510
COBOL Completions3
Total Stars58
% of votes with a positive feedback rating96% of 434
Total "Very Satisfied" Votes400
Total "Somewhat Satisfied" Votes32
Total "Not Satisfied" Votes2
Total Rank Assessments9
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • PiotrBerebecki Avatar
  • user8476848 Avatar
  • akar-0 Avatar
  • dfhwze Avatar
Ad