Ad
  • Default User Avatar

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

  • Default User Avatar

    When I attempt this kata, it will LITERALLY not let me get the basic test correct. I get the following error:

    TypeError: Cannot read property '1' of undefined

    ...

    Cases that cause the error:

    return Math.floor(dist);

    return Math.ceil(dist - 1);

    return Number(dist.toString().match(/.*(?=.)/)[0]);

    var dist = -1;
    ...
    return Math.ceil(dist);

    ...

    Cases that do not throw the error, but get the wrong answer:

    return Math.ceil(dist); //returns 890

    return dist.toString().match(/.*(?=.)/)[0]; //returns '889';

    etc.

    Why won't it let me get the right answer?