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.
"A higher order function is any function that takes a function as a parameter or returns a function as its result." These HOCs allow us to abstract some operations that are being performed repeatedly (in this kata, we want to multiply each index's value by two). Instead of, for example, writing a
for loop
, we can usemap
, a classic example of an HOC.map
takes an array and a function as arguments, which then uses this function to transform each item in the array, returning a new array with the transformed data. We like that it returns a new array because we want to avoid mutating any data. HOC's can do more than just manipulate array, for example,Function.prototype.bind
is another HOC in JavaScript. Just keep practicing, find really good examples of what it is that you don't understand, and try to find the meaning in them and why they're useful. These things don't come naturally for everyone, and it took me a while to understand and appreciate some concepts of programming until I had real life use cases for them.Sources:
Thanks both. I've actually got no issues at all with syntax and it's nothing to do with JavaScript itself. My issue is with understanding higher-order functions. That's something I struggle a lot to understand currently.
Make sure to understand where JavaScript came from before you dive into some of the newer stuff :)
I did this too but I don't understand at all how/why it works. Could you explain to me? Thanks. :-)
I am very sad