As a beginner applying the lodash library in the functional programming, I found that ._flow doesn't excute the functions put in. My question is how do I apply map, reduce, or filter inside the flow? Or anything that I did wrong? Any help is highly appreciated.
For example:
const _=require('lodash');
const scores = [50, 6, 100, 0, 10, 75, 8, 60, 90, 80, 0, 30, 110];
const newArray=_.filter(scores,val=>val<=100);
const newArray2=_.filter(newArray,val=>val>0);
console.log(newArray2);
// the output is
/*[
50, 6, 100, 10, 75,
8, 60, 90, 80, 30
]*/
However, when I make it two separate functions and put into flows, it doesn't do anything.
const newRmvOverScores=_.filter(val=>val<=100);
const newRmvZeroScores=_.filter(val=>val>0);
const aboveZeroLess100=_.flow(newRmvOverScores,newRmvZeroScores)(scores);
console.log(aboveZeroLess100);
// the output is:
/*[
50, 6, 100, 0, 10, 75,
8, 60, 90, 80, 0, 30,
110
]*/
Several references I've found:
[1]Using lodash, why is the map method within flow not working? [2]https://lodash.com/docs/4.17.15#flow