Skip to content

Instantly share code, notes, and snippets.

@1n3ffbl3
Created April 12, 2018 10:29
Show Gist options
  • Save 1n3ffbl3/d094a92840ae8db1b839ddc186291761 to your computer and use it in GitHub Desktop.
Save 1n3ffbl3/d094a92840ae8db1b839ddc186291761 to your computer and use it in GitHub Desktop.
HigherOrder from codewars
https://www.codewars.com/kata/coding-meetup-number-2-higher-order-functions-series-greet-developers
*/
You will be given an array of objects (associative arrays in PHP) representing data about developers who have signed up to attend the next coding meetup that you are organising.
Your task is to return an array where each object will have a new property 'greeting' with the following string value:
Hi < firstName here >, what do you like the most about < language here >?
var list1 = [
{ firstName: 'Sofia', lastName: 'I.', country: 'Argentina', continent: 'Americas', age: 35, language: 'Java' },
{ firstName: 'Lukas', lastName: 'X.', country: 'Croatia', continent: 'Europe', age: 35, language: 'Python' },
{ firstName: 'Madison', lastName: 'U.', country: 'United States', continent: 'Americas', age: 32, language: 'Ruby' }
];
/
function HigherOrder()
arg: 1
* an array of contact info objects:
- firstName : string
- language : string
- lastName: string
- country: string
- continent: string
- age: number
- language: string
* return : new array with old objects and new property calls 'greeting'
- Greeting: string
- firstName : string
- language : string
- lastName: string
- country: string
- continent: string
- age: number
- language: string
* behavior: this function HigherOrder takes <firstName> and <language> to create
new property calls greeting
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment