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. )Thanks very much for your reply. I haven't read "eloquent Javascript", but it's on my "must-read" list. I'm still feeling my way around Javascript, but you're the 3rd or 4th person to mention "eloquent Javascript", so it's apparently a very useful source.
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
}
Should this be included in Fundamentals? Everyone has his own definition of "fundamentals" but, from my perspective as someone who has done only the Codecademy course in Javascript and a handful of katas, the 'fundamental' tag seems a bit misplaced here.
If one uses 'letorconst` or other ES6 features, the code will get longer due to the transformation by babel. That should get mentioned in the description.
Pls help I've done a character count elsewhere it shows 245, the test says 280? I also sneakily tried assigning strings to vars at one point, which brought the actual count down further, but in the test it went even higher! confused..
Check out ternary operators :)
Please add this information into description. It can be confusing.
Bravo Peter \m/
is there a way to do this in fewer than 250 chars without using regex? My only exposure to JS is completing a Codecademy course and some level 8 and level 7 katas. Based on my limited experience, I instinctively reached for a 'switch' statement, but that puts me around 350 chars, even after smushing my code together as much as possible. I suspect that I'm missing a more elegant solution, but I don't know regular expressions.
Thanks, Dean! I'll get the hang of this environment soon.
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
I'm trying to teach myself Javascript to prepare for an assessment test given by Full Stack. I took Codecademy's online "Javascript" course, which felt like a good place to start. Now I'm trying some CodeWar challenges. I started at level 8 as would anyone, and I've submitted a few katas (Isograms, Remove the Minimum, Grasshopper - Grade book), but now I'm stuck on one that looks like it should be straightforward - "A function within a function". I'm trying to solve this, and I hate to put up the white flag, but I feel like I've run out of ideas. My question is whether I can find the solution to this somewhere. I want to move on to other katas and to continue learning, but I hate the feeling of moving past something without understanding it. Can someone offer any guidance on this?