you are right. I have misread the challenge

Still one problem : 

The output now looks like this : 

~~~

[ { message: 'Cupidatat reprehenderit qui dolor ex labore amet.'  } , 


~~~

where the output must look like this : 

~~~

[  message: 'Cupidatat reprehenderit qui dolor ex labore amet.' , 

~~~

So I think I need to use map to fetch the messages one by one or is there 
another way .

Roelof




Op dinsdag 20 januari 2015 18:34:44 UTC+1 schreef Alexander Behrens:

> @Roloef: Ist your sample array full of short texts? Because your example 
> filters out any short text. Therefore your returning array is empty. You 
> have to change the condition from element.length > 50 to element.length <= 
> 50
>
> On Tue, Jan 20, 2015 at 5:35 PM, Scott Ganyo <[email protected] 
> <javascript:>> wrote:
>
>> That too. :)  And... you could simplify your function if you wish:
>>
>> module.exports = function getShortMessages(messages) {
>>
>>     function small_message(item) { return item.length < 50; }
>>
>>     return messages.filter(small_message);
>> }
>>
>> Scott
>>
>> On Jan 20, 2015, at 8:27 AM, 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] <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/144D62D9-078A-43BA-8FE9-740E0859F5A1%40apigee.com
>>  
>> <https://groups.google.com/d/msgid/nodejs/144D62D9-078A-43BA-8FE9-740E0859F5A1%40apigee.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/5f21e0cc-fd94-4f8a-802e-ba339becdea6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to