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.
Very readable! Helped me reflect on my solution and see a new way of doing things. Thanks :)
i starts as the char code of the first entry, it will increment if it matches in the .map to be the one more (the i++). If it doesnt match at any point then there is a missing letter, and i will stop increasing which will leave i as the char code of the missing letter.
It's useful to go along with pen and paper to see what each operation is doing. Remember that i++ mutates i, and notice that the map is just acting as a forEach here
The peak of human achievement
Yeah. He isn't storing or using the array
.map
creates. Just iterating over it to conditionally incrementi
. So that's why I asked why he used.map
and not.forEach
forEach: This iterates over a list and applies some operation with side effects to each list member (example: saving every list item to the database)
map: This iterates over a list, transforms each member of that list, and returns another list of the same size with the transformed members (example: transforming list of strings to uppercase)
ref: https://stackoverflow.com/questions/34426458/javascript-difference-between-foreach-and-map
I have a hard time understanding the ternary operator usage here. Could someone please explain this solution in more depth? It just seems so sharp and to the point! I really want to understand this better
wow.. achieving the same result took me 20 lines of code and 2 hours of straining my brain.
I cannot believe this is how smooth the code could be. Lots to learn!!