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.
Eh, no? There's nothing more to this than the simple condition in this solution...
Good solution, but there are more actions happening under the hood, even if the entry looks concise
For a lot of users, we make a challeng out of making the answer as short as possible. Spaces are a waste of space ;-)
why don't you put spaces? This is hard to read
ou yeah
Nice one!
smart
This is clever and nice use of recurssion.
I love this solution. I was thinking that essentially all we were doing was a lookup, so an object would have been perfect, and I also wanted to use a switch statement but was too tired to implement it properly. This one is a great example of when to use a hash table for lookup and best use of the Big O consideration of the exercise.
Love it mate, good job. Will keep this kind of approach in mind going forwards.
Smells like redux :D
Literally forgot I could have used a ternery operator :facepalm:
"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 :)
This comment is hidden because it contains spoiler information about the solution
Loading more items...