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.
you don't need such package, method, or function (regex operation)
Why so? Regular expressions are pretty fast. It completes the tests in just over 2s. Your solution takes 1.7s.
In fact, if you pre-compile the regex, this solution runs just as fast as the one you made.
The if statement is not needed. You can just return the result of the comparison.
Effectively what you are doing is:
if condition {
return true
else {
return false
}
This can be simplified to: return condition
This is a very inefficient solution. It requires an extra package, and does a lot of unnecesary string processing.
How?
The newWord variable isn't needed.
The explicit cast also isn't needed, and it is implicit from the defined return type.
The contents of the string is irrelevant.
you could just return remainder1 != remainder2
The comparison of the two values already returns a boolean type.
You are doing:
if true { return true }
return false
You could just do: return conditional-operation
Clever and neat
This comment is hidden because it contains spoiler information about the solution
what does this line mean ?
players[selected].name;
Yes, if you imagine the answer to be [x, y] then the result given must be the one with the lowest value of y.
Yes, it is very efficient, logical and clear.
It fits in with the functional aspects of JavaScript. Why wouldn't it be one of the best practices?
This comment is hidden because it contains spoiler information about the solution