Solved this one with a little try and error.
Roelof
Op dinsdag 20 januari 2015 19:37:41 UTC+1 schreef Roelof Wobben:
> I already did .
>
> I have now this
>
> ~~~
>
> module.exports = function getShortMessages(messages) {
>
> function smallerfifty(element) {
> return element.message.length < 50;
> }
>
> return messages.filter(smallerfifty)
>
>
> }
>
> ~~~
>
> and this output :
>
>
> ~~~
>
>
> [ { message: 'Eiusmod adipisicing esse labore magna elit irure.' },
>
> { message: 'Amet esse excepteur mollit excepteur.' },
> ]
>
> ~~~
>
> where it schould be
>
> ~~~
>
>
> [ message: 'Eiusmod adipisicing esse labore magna elit irure.' ,
>
> message: 'Amet esse excepteur mollit excepteur.' ,
>
>
> ~~~
>
>
>
> Op dinsdag 20 januari 2015 19:23:10 UTC+1 schreef Alexander Behrens:
>
>> Change return item.length < 50 to return item.message.length < 50
>>
>> On Tue, Jan 20, 2015 at 5:52 PM, Roelof Wobben <[email protected]>
>> wrote:
>>
>>> oke,
>>>
>>> But still my answer is failing . See this output :
>>>
>>> ~~~
>>>
>>>
>>> ACTUAL EXPECTED
>>>
>>>
>>> ------ --------
>>>
>>>
>>> "[]" != "[ 'Et anim veniam dolor ipsum
>>> consectetur.',"
>>>
>>>
>>> "" != " 'Magna velit non do ea aliquip nulla
>>> minim.',
>>> "
>>>
>>>
>>>
>>> null != " 'Minim magna proident consectetur
>>> dolore.',"
>>>
>>>
>>> null != " 'Minim sint minim reprehenderit
>>> laboris minim
>>> .',"
>>>
>>>
>>>
>>> null != " 'Nisi duis exercitation nisi tempor
>>> ex magna.
>>> ',"
>>>
>>>
>>>
>>> null != " 'Dolor nulla deserunt cupidatat
>>> pariatur.',"
>>>
>>>
>>> null != " 'Aute laboris eiusmod nulla do
>>> cupidatat.',"
>>>
>>>
>>> null != " 'Labore non sit mollit irure
>>> labore.',"
>>>
>>>
>>> null != " 'Anim non ullamco culpa ea sint do
>>> sunt.',"
>>>
>>>
>>> null != " 'Non amet duis dolore officia anim.',"
>>>
>>>
>>> null != " 'Irure ex commodo amet id tempor do
>>> cillum.',
>>> "
>>>
>>>
>>>
>>> null != " 'Laborum fugiat sunt eu veniam aute.'
>>> ]"
>>>
>>> null != ""
>>>
>>> # FAIL
>>>
>>>
>>> ~~~
>>>
>>> So something is not right here.
>>>
>>> Roelof
>>>
>>>
>>>
>>> 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]>
>>>> 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]>
>>>>> 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].
>>>>>> 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/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].
>>>>> 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/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/9da22225-5738-4517-bd9c-6284853a8b12%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/nodejs/9da22225-5738-4517-bd9c-6284853a8b12%40googlegroups.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/5f775cd3-c179-42fd-a065-f4e9b20ee6bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.