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.
In what language would assignment to
p0
mutate anything in a way noticeable for a caller? No matter ifp0
holds a reference to an object, or a value, reassignment ofp0
parameter won't mutate anything on the outside†. Or will it?† I can point one language where reassignment of an argument can mutate values seen to the outside (without changing the syntax of a call), I wonder if there's more and what they are.
Whilst in JS, assuming p0 is a number, then mutation isn't going to happen, for people coming in from other languages it's uncomfortable to see. Generally it's a bad habit to 'mutate' arguments as you're increasing the cognitive load on future coders to know whether the argument is a reference or not. For example, if the code is refactored and now p0 is given as an object or an array - if the coder niavely updates the code, they could easily start actually mutating the argument. Of course, good testing will guard against this, but it is a bad habit unless you want mutation outside of the function.
I agree that we should avoid data mutations at all costs, but there is no need for this since we aren't working with references.
This is just completely wrong and stupid. You obviously have no idea how JS even works.
surely let rather than var
bigres should really be typed since it's typescript, but this is better than the efforts that solve it in JavaScript alone.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I like the decomposition here, both the regex definition and the comparison order could be different in the future, this is maintainable code. Very clear. I think shows that just because we can solve a problem in one line, does not mean that we should solve a problem in one line. Voting as best practice.
This comment is hidden because it contains spoiler information about the solution
There is no need to assign P0 but doing so avoids argument mutation. It's good defensive programming since JavaScript is fling those function parameters about by reference.
argument mutation of p0 should be avoided, we can't say if that will not affect the behaviour of p0 outside the function. The test cases state p0 as a number, however it could be supplied as a variable. For the sake of a single extra let statement, it's worth the defencive effort.
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
Loading more items...