Closed ivanbuncic closed 6 years ago
Hello dear people, I tried to run the second snippet from the very begging of the book ...
`var sumOnlyFavorites = FP.compose( [ FP.filterReducer( FP.gte( 10 ) ), FP.filterReducer( FP.lte( 20 ) ) ] )( sum );
var printMagicNumber = FP.pipe( [ FP.reduce( sumOnlyFavorites, 0 ), constructMsg, console.log ] );
var numbers = [4,10,0,27,42,17,15,-6,58];
printMagicNumber( numbers ); // The magic number is: 42
// ***
function sum(x,y) { return x + y; } function constructMsg(v) { return The magic number is: ${v}; }`
The magic number is: ${v}
and got the error:
**Uncaught ReferenceError: FP is not defined at <anonymous>:1:24**
What am I doing wrong here?
Kindest regards Keep on rocking!
That's a purely illustrative snippet, not one that's designed to be run. FP here is a placeholder for whatever library you might use.
FP
I knew it was me :)))
Hello dear people, I tried to run the second snippet from the very begging of the book ...
`var sumOnlyFavorites = FP.compose( [ FP.filterReducer( FP.gte( 10 ) ), FP.filterReducer( FP.lte( 20 ) ) ] )( sum );
var printMagicNumber = FP.pipe( [ FP.reduce( sumOnlyFavorites, 0 ), constructMsg, console.log ] );
var numbers = [4,10,0,27,42,17,15,-6,58];
printMagicNumber( numbers ); // The magic number is: 42
// ***
function sum(x,y) { return x + y; } function constructMsg(v) { return
The magic number is: ${v}
; }`and got the error:
What am I doing wrong here?
Kindest regards Keep on rocking!