the input variable looks like this : 

[ { message: 'Cillum quis laborum incididunt aliqua est et consectetur ipsum 
elit d
eserunt.' },                                                                    
   
  { message: 'Dolor incididunt velit sit deserunt laboris sunt nostrud cillum 
Lorem
 sit occaecat dolore aute ex.' },                                               
   
  { message: 'Id fugiat veniam do eu.' },                                       
   
  { message: 'Consequat id non nulla culpa dolore eu irure deserunt.' },        
   
  { message: 'Mollit qui elit tempor eiusmod eu.' },                            
   
  { message: 'Aliquip quis aute cupidatat adipisicing irure nisi consectetur.' 
},  
  { message: 'Adipisicing ea cupidatat quis sunt eu id velit voluptate officia 
cill
um elit aute aliqua.' },                                                        
   
  { message: 'Qui incididunt aute eiusmod Lorem cillum.' },                     
   
  { message: 'Sunt non ut eiusmod id magna sunt culpa labore aliquip.' },       
   
  { message: 'Mollit exercitation sunt esse reprehenderit consequat laboris 
irure i
n dolore non.' },                                                               
   
  { message: 'Incididunt Lorem minim non sunt est mollit non do nulla elit qui 
ipsu
m.' },                                                                          
   
  { message: 'Ea exercitation occaecat nulla irure eiusmod pariatur enim ipsum 
duis
 pariatur pariatur.' },                                                         
   
  { message: 'Consequat ad labore occaecat magna.' },                           
   
  { message: 'Sunt commodo veniam consequat ea exercitation incididunt esse 
nostrud
 elit labore ipsum aliquip.' },                                                 
   
  { message: 'Do deserunt consectetur id pariatur culpa.' },                    
   
  { message: 'Magna consectetur irure consequat duis consequat dolore duis 
exercita
tion eiusmod id aute exercitation.' } ]   



Maybe on some way use the map function so every item in the array is used. ?


Op dinsdag 20 januari 2015 17:48:21 UTC+1 schreef Alexander Behrens:

> Also, you can pass the function as an argument directly:
>
> return messages.filter(small_message);
>
> On Tue, Jan 20, 2015 at 5:27 PM, Adrien Risser <[email protected] 
> <javascript:>> wrote:
>
>> Filter is what you're looking for.
>>
>>
>> https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
>>
>> On Tue, Jan 20, 2015 at 5:06 PM, Roelof Wobben <[email protected] 
>> <javascript:>> wrote:
>>
>>> Hello, 
>>>
>>> I try to learn functional javascript by following the functonial 
>>> workshop of nodeschool.
>>>
>>> Now I have to filter out all the messages which lenght are shorter then 
>>> 50. 
>>>
>>> So I thought this would work : 
>>>
>>> ~~~
>>>
>>> module.exports = function getShortMessages(messages) { 
>>>
>>>     function small_message(item) 
>>>
>>>     { return item.length < 50 ; } 
>>>
>>>
>>>     messages.map(function(message) 
>>>
>>>      { return small_message(message) }) } 
>>>
>>> but when I test it I see a empty array as answer  
>>>
>>> Can someone explain where my thinking took the wrong path ?
>>>
>>> Roelof
>>>
>>>
>>>  -- 
>>> Job board: http://jobs.nodejs.org/
>>> New group rules: 
>>> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
>>> Old group rules: 
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "nodejs" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected] <javascript:>.
>>> To post to this group, send email to [email protected] 
>>> <javascript:>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/nodejs/2bb9460e-96ef-4160-98e5-afe713f6ea96%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/nodejs/2bb9460e-96ef-4160-98e5-afe713f6ea96%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Adrien Risser,
>> Freelance Node.js Consultant
>> M. +33 6 59 60 32 58
>>  
>> -- 
>> Job board: http://jobs.nodejs.org/
>> New group rules: 
>> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
>> Old group rules: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/nodejs/CAKGrCFhq%2BFFN655s2A4QbJ5fmPUK%3DNxOU1h9cxRAPsLekJkEYg%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/nodejs/CAKGrCFhq%2BFFN655s2A4QbJ5fmPUK%3DNxOU1h9cxRAPsLekJkEYg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/de5c5ed0-4e89-4427-91e3-61fac1089556%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to