getify / Functional-Light-JS

Pragmatic, balanced FP in JavaScript. @FLJSBook on twitter.
http://FLJSBook.com
Other
16.6k stars 1.96k forks source link

Very first example in the book throws an error - or is it just me? #164

Closed ivanbuncic closed 6 years ago

ivanbuncic commented 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}; }`

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!

getify commented 6 years ago

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.

ivanbuncic commented 6 years ago

I knew it was me :)))