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.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
"An arrow function expression has a shorter syntax than a function expression and does not have its own this, arguments, super, or new.target..."
Implicit returns in arrow functions are dependant on the lack of a body block, not being one-line.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#Function_body
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
That is the spread operator. It spreads the contents of an iterable (in this case an array), into separate function arguments.
Given the string
p1 = '1:3'
this:is approximately equal to:
Hi Matorzinho!
Sure thing:
You can think of the comma operator as a way to compose multiple expressions into a single expression chain.
The expressions are evaluated in order, with each of their results discarded. The final expression however (the last one in the chain) returns its result as the result of the combined expression.
For Example:
Could be re-written with the comma operator as:
This can be useful if you need to use multiple expressions in a place that can only take a single expression. However, I haven't seen many uses that wouldn't be improved by being more explicit so I try to reserve its use for code golf.
Because this function now contains a single statement, it could be further-reduced.
Also worth noting that the comma has the lowest operator precedence, so consider parentheses.
Hope this helps!
This comment is hidden because it contains spoiler information about the solution
This is a duplicate of Balanced Delimiters
Actually, the "Enumerable Magic" katas are explicitly for beginner exploration.
See previous discussions:
The Set constructor stores unique values, and accepts an iterable (like an Array or a Set) as its one argument. The construction removes duplicate values determined via the
===
operator.The
...
Spread operator can spread an iterable (like a Set or an Array) into multiple arguments or array elements.A more verbose syntax for this solution might be:
More documentation if needed:
This is more of a test for whether you can figure out the author's intent than it is of your JS skills.
At the very least this needs more tests with varying insertions. Not a single hard-coded test.
Without digging into the idiosyncrasies of each solutions' api calls on both platforms, it's hard to say. The only thing I can think of is differences in native ES5, native ES6, and transpiled ES6 code. Or possibly, differences in the JavaScript engines themselves (spidermonkey, v8, etc.). The engines aren't implemented in the same ways, so their performance varies here and there.
That is correct. This line prepends five zeros to
binString
and then takes only the last five digits. This ensures that the string is always exactly five digits in length, with the missing digits on the left set to0
(off).When in doubt: don't. (This post is fairly reasonable)
While it is indeed more difficult to do this in a safe way than other options, it can be done. In a small, self-contained project like a kata, where functionality and intent of the extension are clear, there shouldn't be any issues.
That being said, I wouldn't copy/paste this code into a production project.
Quite right. This has been taken into consideration in a new solution. Thanks!
Loading more items...