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.
Description is not written well.
Your "spy" only saves the last return value of func it's spying on, but as I understood the problem it should keep all the returned values and answer the question "did the func ever return this value?...". It's just a small change, though.
It's considered not a good practice to use
[].someFn.apply(...)
. You're creating a new array in memory. Best to useArray.prototype.someFn.apply(...)
instead.Better test cases needed; the quiz requirements say the function should return an array with 'numbers first, method names after' without mentioning any particular order, while the test cases are sensitive to the order of the elements.
The
join.when()
function should return errors and values in the same order the callbacks had beenadd
ed even if thefutures
were resolved in different order than they were added.The current test cases are not testing for it so a wrong solution passes.
omg, parenthesis are omitable... That's awful! Good to know, though.
You should consider the case when neither after, nor before functions exist ;)
Kata description is a little misleading: it gives an impression that the clean function should return an array of removed values, while it is expected to return the filtered array of "truthy" values.
Thank you very much! I don't know whether I would ever notice that :)
It turned out to be a boring "missed by 1 iteration" mistake after all.
Enjoyed this kata a lot!
I usually keep trying and trying to find a mistake without asking questions in the comments, but this time I am really baffled. I am failing only one test case, the one with the line lenth of 25.
How is this possible? I'm fitting text into one line less than expected. And here is my output:
That's a great explanation, thank you! I've been trying to examine it very closely and everything seems to have become clear, except for the "unexpected" part.
It may be "unexpected", but I would still like to understand it. Why does obj.fn.val becomes changed at all.....
Wait, I think I've finally got it right now while I am writing this. Since
fn
is now 'made' (i think it's a bad word) ofobj.fn
, we can actually usefn.val
, which is by now equal to 1001. When we apply the function itself asthis
, it of course changes the value which used to beobj.fn.val
and is nowfn.val
. I think I had a wrong understanding thatthis
by default refers to the function itself. But it's not the function, it's the context where the function is triggered.Your example is very helpful, thanks again.
I have a question. What if in the Event.prototype.emit we apply not
null
asthis
, but the function itself? Like this:Can someone explain if this can be better or worse in some cases?
I've come up with solution almost by accident, while just playing around with logical operators.
Interesting to know that the logical expression when used with non-boolean values — "expr1 && expr2" — will always return the value of the second (last) expression, except when one of those expressions evaluates to 'undefined', 'null', zero (0) or an empty string (''). In that case it will return the value of that "false" (if you could say so) expression.