Ad
  • Default User Avatar

    There is currently no test case that checks the semantics stated in the description.

    Your function will iterate through the members of the array in order until the provided iterator function returns true; at which point your function will return that item's index.

    The function must not call the iterator function after the match is found.

    The following test will break even the most popular solution (ha-ha).

    var timesCalled = 0;
    var alwaysTrue = function(v, i) {
      timesCalled += 1;
      return true;
    };
    
    Test.expect(findInArray([1, 2, 3], alwaysTrue) === 0);
    Test.expect(timesCalled === 1);
    
  • Default User Avatar

    Some incorrect solutions use String#trim to get rid of whitespace.

    Please add the following simple test:

    checkComments ' banana', [], ' banana'
    
  • Default User Avatar

    \s catches newline characters, no need for \n in your first RE.

  • Default User Avatar

    The trick is so clever!

  • Default User Avatar

    This is because toFixed() returns a string but number is expected.

    +n.toFixed(3) works perfectly.

  • Default User Avatar

    assertSimilar can't distinguish -Infinity, +Infinity, and "null" from actual null, and therefore some incorrect solutions pass. I would either state the requirements explicitly or use assertEquals instead.

    Also I think it would make sense to expect Infinity in case of a vertical line and null in case of equal points.

  • Default User Avatar

    I can add that it is not stated in the description at all that an empty tag name indicates a text node. Killed some time and finally cheated to discover this requirement.

  • Default User Avatar

    FYI, Math.pow(10, -7) can be written in literal form as 1e-7.

  • Default User Avatar

    This is not what katas are designed for.

    In our dojo, kata are real code challenges focused on improving skill and technique. Some train programming fundamentals, while others focus on complex problem solving.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Yes, if there is any other identifier named "func", it hides the function from the outer environment.

  • Default User Avatar

    Fails (with TypeError) on this one:

    function foo(func) { return func; }

    The hardest part of this kind of solutions is generating unique identifiers.

  • Default User Avatar

    You do not need to decrement 'i' inside the inner function.

  • Default User Avatar

    Actually it is a single-RegExp problem (or maybe 2 or 3).