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.
Thanks.
By copy, do you mean the spread?
Array.keys()
creates an iterator object, you need to spread it to get the array.The description states that n wont be less than than 10.
Should your tests include
NaN
as a possible value in the Array?typeof NaN === 'number'
=>true
This comment is hidden because it contains spoiler information about the solution
you missed my point :)
It's not until the operation that the value is replaced by
0
, before the addition it's not a Number and therefore not an integer.The function shouldn't have reached the point where you sum the values, Unless you ask for the values to be converted into numbers first (where possible) and then return '0' if the array contains non-integer values.
This comment is hidden because it contains spoiler information about the solution
What I'm using there is just an Object
{}
, but instead of string keys I'm using computed property names which were added in ES2015.These allow you to use an expression, function, variable as a key which gets evaluated.
So the Object keys above will either be True or False and I'm returning the property that is true by adding the
[true]
after the Object.owade is correct, your initial tests have
'very\quickly'
Sure,
Filter iterates over each value (v) and creates a new Array containing only the values that when passed into the supplied function return true.
The function I've used returns Array.includes which tests whether the value is present in an array and returns true or false.
What might seem confusing is the ! operator which negates a value (turns true to false and false to true).
So I've basically written: arr1 filter the values that are NOT included in arr2.
I've used the same on arr2 and then joined them together using concat.
Hope that makes some sense.
tbh. I'm not even sure this is a valid solution. It doesn't work in some cases, even though it passes all the current tests.
Shouldn't you mention rest as well as spread?
Although they look identical they are different. Spread separates the values of an iterable and is used inside function calls and Array literals, while rest gathers individual values into an array and is used for rest parameters and destructuring..
Two of the examples(1 & 3) use rest.
'cause I was trying to use regex, fixed now. Thanks for letting me know :)
I have a bad habit of just marking my solutions as best practice whether they are or not.
I personally don't think users should be able to up vote their own solutions.
You're right though, I'll remove the vote :)
1 is not a prime number.