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.
Has anybody tested the performance of this ? it feels to me like recursivity would be less efficient than a regular loop here
This comment is hidden because it contains spoiler information about the solution
very clever and easy to understand answer
We all learn, part of the process. This platform will defo make you a more well rounded dev
What a fantastic one liner LOL
This comment is hidden because it contains spoiler information about the solution
Since we were using numbers as the input this makes so much sense to do instead of writing our that long switch statement that I used for this.
Genius
he just sort them from 0 to 9 and uses the input as index when you type 1 as input you will get the value at index one from the array
can someone explain how this works? they dont provide actuall numbers.... im confused. is [n] somehow represent the numbers?
this is so much better than typing each case out
Dang...I wish I could take back my solution now. I even put break statements on my switch cases...and then realized they aren't needed.
haha I knew there had to be a faster way while writing out the switch statement and you found it!
If you don't declare variables they are automatically global in JavaScript which is bad as it can pollute other code places or even overwrite other variables. It is done here because this code is trimmed to have as few characters as possible (don't know why they use spaces though) and it can be expected that there are no side effects.
let
andconst
only define the function in the current scope.Since function definitions normally don't change it is best to define them with
const
.What is the fundamental difference for real code, if in this decision at the very beginning you also write "let". And what is the right way?
Loading more items...