Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Yes, absolutely.
It may not be "Simple", but function composition certainly is "Fundamental".
Look at it this way:
"1243".split("").sort().join("")
is also function composition, just with a different syntax.( That could have been
compose( join(""), sort(), split("") )( "1243" )
. Mind that the arguments tocompose
are functions. )Did you read eloquent javascript? The main thing that I think would be confusing is scope and closures, so perhaps looking into those two topics would be helpful.
function mainScope (args) { //main function
var newfunction = function(){ //still has access to variables accessible in mainScope
return args; //can manipulate args as expected
};
return args;
}
function secondaryScope (args) { //new function
newFunction(); //would throw error
}
Check out ternary operators :)
You should post this in the discuss thread of the kata you are having trouble with. You will see discuss with some speech bubbles just below the katas title. I believe this is the kata you are talking about. function within a function
There are lots of things you can do with functions in javascript. In Javascript functions are actually just a special type of object so they can be returned or even passed around.
so a function that returns another function would look something like this
I hope that helps. If you are still stuck or just want to learn more about functions in functions here are some things to research on Google