6 kyu

CoffeeScript Comprehensions

305 of 322jhoffner

Description:

CoffeeScript includes the ability to loop over arrays and perform each/select/map type behavior. It provides this without the need to use an external library such as underscore.js.

Utilize the comprehension syntax in the following exercise. The findFirstNames(data, lastNameLength) method needs to be completed so that it will return the first names of people who have a last name with a string length equivalent to the lastNameLength argument.

The following is an example dataset:

people = [
  {firstName: 'Bill', lastName: 'Gates'},
  {firstName: 'Steve', lastName: 'Jobs'},
  {firstName: 'Brendan', lastName: 'Eich'},
  {firstName: 'Yukihiro', lastName: 'Matsumoto'},
  {firstName: 'Jeremy', lastName: 'Ashkenas'}
]

The method would be called like the following:

firstNames = findFirstNames(people, 4)
# firstNames would == ['Steve', 'Brendan']
Arrays
Fundamentals

Similar Kata:

More By Author:

Check out these other kata created by jhoffner

Stats:

CreatedMar 12, 2013
PublishedMar 13, 2013
Warriors Trained485
Total Skips38
Total Code Submissions1332
Total Times Completed322
CoffeeScript Completions305
Total Stars3
% of votes with a positive feedback rating85% of 40
Total "Very Satisfied" Votes29
Total "Somewhat Satisfied" Votes10
Total "Not Satisfied" Votes1
Ad
Contributors
  • jhoffner Avatar
  • kazk Avatar
  • KayleighWasTaken Avatar
Ad