Ad
  • Default User Avatar

    Not an issue.

  • Custom User Avatar

    Same here.

  • Custom User Avatar

    Non, "If such an element is found, some immediately returns true. Otherwise, ..."

    some returns -1

    right?

  • Custom User Avatar

    some executes the callback function once for each element present in the array until it finds one where callback returns a true value. If such an element is found, some immediately returns true. Otherwise, some returns false.

  • 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

    The slope of a vertical line is not infinity, it does not exist.

  • 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.

  • Custom User Avatar

    Nice excercise. Would have liked an explanation of what the "slope" is in the description, just to be clear. But otherwise, works quite well.

  • 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.

  • Loading more items...