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.
No. The requirement is to 'filter out the strings'. We don't really care if the left overs are numbers, objects, or anything else for that matter. Just don't include the strings!
Found the answer.
it's not the spread operator
...
, but looks like it. using...
in the function parameter definition makes it a 'rest parameter' that creates an array of all arguments AND creates thatarguments
object as usual.Useful for variadic functions with a unknown number of parameters.
Reference: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/rest_parameters
Can you help me understand the spread operator and reduce here.
a
is the set of arguments, and...
will 'spread' the set of arguments as parameters to the function.However, the how is
a.reduce
possible?a
will be the arguments object as far as I understand, andarguments
is 'arrray-like', but not an array, and will usually throw an error that 'reduce' is not a function onarguments
.What's happening here?
This comment is hidden because it contains spoiler information about the solution
I see, then these websites are wrong, when they state that the let keyword is part of the ES6 and newer:
https://medium.freecodecamp.com/5-javascript-bad-parts-that-are-fixed-in-es6-c7c45d44fd81#.xuzvyk491
https://strongloop.com/strongblog/es6-variable-declarations/
https://davidwalsh.name/for-and-against-let
Sorry, just a little confused.
I used recursion, but I assumed that you'd need to have a check on whethere "next" is null, but of course null is falsey, so the concat should just fail at the end. Nice, succinct.
This will only work for ES6, right?
Additionally, I didn't even think about putting a conditional test as the property value in an object! Very succinct and novel.