Ad
  • Custom User Avatar

    The specifications indicate that "Your solution should be recursive," while this is not tested. While "should" is a bit of a washy word, other specifications like "Your solution should be 'in place' meaning it return the original object, not a copy." are explicitly tested.

    For example, iterative stack-based solutions like this work just fine. This line in the specifications should either be tested or reworded as a hint.

  • Custom User Avatar

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

  • Custom User Avatar

    I am not sure what test case I am failing. I am able to pass all of the My Test cases, but when I submit I get:
    Test Passed
    Test Passed
    Value is not what was expected
    2 Passed
    1 Failed
    0 Errors
    Process took 51ms to complete

    If someone could point me to what test case I am failing that would be great.
    Here are my test cases:
    //Some garbage data
    var data = {
    foo: "dynamic",
    bar: {
    baz: ["dynamic"]
    },
    dynamic: true
    };

    //Your solution
    var result = solution(data, "static");

    //Expect the values to have been changed
    Test.expect(result.foo === "static");
    Test.expect(result.bar.baz[0] === "static");

    //None of this nonsense
    //JSON.parse(JSON.Stringify(data).replace(/dynamic/g, "static"))
    Test.expect(result.hasOwnProperty("dynamic"));
    Test.expect(!result.hasOwnProperty("static"));

    //Return the original object
    Test.expect(result === data);

    Test.assertEquals(solution('dynamic', 'x'), 'dynamic');
    Test.assertSimilar(solution({ foo: 'not dynamic'}, 'static'), { foo: 'not dynamic' });

  • Custom User Avatar

    Nice kata.

    Two test cases that I miss (and that would invalidate a bunch of solutions, including mine) are:

      Test.assertEquals(solution('dynamic', 'x'), 'dynamic');
      Test.assertSimilar(solution({ foo: 'not dynamic'}, 'static'), { foo: 'not dynamic' });
    

    Thanks for your kata!

  • Custom User Avatar

    There are a lot of strange criteria that seem to be tacked on to the problem and seem to not really add much, and just point the coder to a specific set of solutions, rather than making it more challenging or thought provoking.

  • Default User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Added a clarification.

  • Custom User Avatar

    Updated the description and added some example tests.

  • Default User Avatar

    This kata is a bit lacking on the description. Some examples and ideally a starter test case would be very useful to help push this through.

  • Custom User Avatar

    It's not apparent to me from the description that the replacement needs to be recursive. Maybe calling it a 'deep' search and replace would be better.

  • Default User Avatar

    Kata description is a bit misleading. It should be mentioned, that the main object object's properties may also be objects (nesting!). At first I thought there would be no nesting. Moreover you should add an example.