Ad
  • Custom User Avatar

    Description is not written well.

  • Custom User Avatar

    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.

  • Custom User Avatar

    It's considered not a good practice to use [].someFn.apply(...). You're creating a new array in memory. Best to use Array.prototype.someFn.apply(...) instead.

  • Custom User Avatar

    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.

  • Custom User Avatar

    The join.when() function should return errors and values in the same order the callbacks had been added even if the futures were resolved in different order than they were added.

    The current test cases are not testing for it so a wrong solution passes.

  • Custom User Avatar

    omg, parenthesis are omitable... That's awful! Good to know, though.

  • Custom User Avatar

    You should consider the case when neither after, nor before functions exist ;)

  • Custom User Avatar

    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.

  • Custom User Avatar

    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!

  • Custom User Avatar

    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.

    Line count is not equal 35 - Expected: 35, instead got: 34

    How is this possible? I'm fitting text into one line less than expected. And here is my output:

    Lorem   ipsum  dolor  sit
    amet,         consectetur
    adipiscing          elit.
    Vestibulum sagittis dolor
    mauris,    at   elementum
    ligula  tempor  eget.  In
    quis   rhoncus  nunc,  at
    aliquet  orci.  Fusce  at
    dolor   sit   amet  felis
    suscipit tristique. Nam a
    imperdiet  tellus.  Nulla
    eu    vestibulum    urna.
    Vivamus         tincidunt
    suscipit     enim,    nec
    ultrices   nisi  volutpat
    ac.   Maecenas  sit  amet
    lacinia  arcu, non dictum
    justo. Donec sed quam vel
    risus  faucibus  euismod.
    Suspendisse       rhoncus
    rhoncus      felis     at
    fermentum.   Donec  lorem
    magna,  ultricies  a nunc
    sit     amet,     blandit
    fringilla     nunc.    In
    vestibulum velit ac felis
    rhoncus     pellentesque.
    Mauris  at  tellus  enim.
    Aliquam  eleifend  tempus
    dapibus.     Pellentesque
    commodo,  nisi  sit  amet
    hendrerit fringilla, ante
    odio   porta   lacus,  ut
    elementum justo nulla et
    
    

    Any hints?

  • Custom User Avatar

    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.

    fn.apply(fn); // 1002 -> don't expected behaviour

    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) of obj.fn, we can actually use fn.val, which is by now equal to 1001. When we apply the function itself as this, it of course changes the value which used to be obj.fn.val and is now fn.val. I think I had a wrong understanding that this 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.

  • Custom User Avatar

    I have a question. What if in the Event.prototype.emit we apply not null as this, but the function itself? Like this:

    handler.apply(handler, args);

    Can someone explain if this can be better or worse in some cases?

  • Custom User Avatar

    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.