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.
Exactly what I did too :')
Having this problem memorized on my anki deck really made a difference.
This is my solution also, was good to be reminded of the arr.reverse function, but seems like there should be an easier way to reverse a str.
Good job! Happy coding.
Legit this is why programming is an art. Now I learned like three things compared to my solution.
ahhh yes, i could have saved a line by using split(). now i know !
very clean, no nonsense solution!
There is a couple of reasons for that, and some of them might be:
Why isn't there a method to reverse a string directly? seems like an oversight.
There are so many possibilities but i still came down to such a solution as the best way to do it. Well done.
Also, this solution is at least 10 years old, maybe arrow function didn't exist back there. ES6 was released in 2015.
1- .split('') method splits a string into an array of strings
exemple : "hello".split('') ==> Output : ['h','e','l','l','o']
2- .reverse() method to reverse order of an array
===> Output : ['o','l','l','e','h']
3- .join('') is to combine elements of an array into one single string and return it
===> Output : 'olleh'
I appreciate the insight. I did initially solve it as a function declaration and refactored as an arrow function expression.
It's probably just because of the context of the question.
Like if someone asked "Hey how do I do this thing in Python?" you wouldn't answer "Well in C++ you can do it like this..."
So in this case, a function with a passed in parameter is given to you, might as well give the solution in the way it was already structured.
Though I do agree that overall, the best practice for legibility in Javascript would be having the solution as a variable function.
wow this is so clean. TY
this one is great
This comment is hidden because it contains spoiler information about the solution
Loading more items...