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.
Concise and clear!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Nice! Is this destructuring? Way neater than trying to keep track of indexes.
This comment is hidden because it contains spoiler information about the solution
I came to say the same; better have one more variable for readability. Also, adding a comment to say why they're subtracting 96 would help for future maintenance. I agree its a nice solution.
i did the same thing and it didnt work, so i just solved it the long way
This comment is hidden because it contains spoiler information about the solution
read the description again and then carry it out manually. pen and paper maybe?
why n, e, n, e, n, e, n, e, n, e - should return false (my code returns false its ok)
but n, s, n, s, n, s, n, s, n, s - should return true? (my code returns false - and test say that it's incorrect, but idk why)
1st test is from "should return false if walk does not bring you back to start"
2nd test is from "should return true for a valid walk"
There's no guideline saying how many return statements you should have. There used to be one, but in modern languages it's no longer applicable. The only practice is that control flow of your function should be clear, what means you should consider structure of your ifs, loops, try/catch blocks, their nesting, and, eventually, returns inside of them. But it's not a matter of numbers, but rather of layout.
It's perfectly valid to exit a function upon verification that it should not, or does not have to, perform any further work.
Besides, in your solution you have other things to worry about than an early return :)
This is a question of best practice. In my solution, I have two return statements in my function. The first checks the length and returns false if length is not 10, the other return statement checks if we finish at our starting position. Should I do the check for length and position in one return statement like I've seen in many solutions? It seems to me having that short-circuit check before I apply any other logic saves on computational work (however miniscule). Should I write functions with only return statement as general best practice?
Trust me it's kind of hard to understand what you are trying to point out, however I see your point through this code. This code work and well done!
This comment is hidden because it contains spoiler information about the solution
Loading more items...