Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
This comment is hidden because it contains spoiler information about the solution
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' });
Nice kata.
Two test cases that I miss (and that would invalidate a bunch of solutions, including mine) are:
Thanks for your kata!
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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Added a clarification.
Updated the description and added some example tests.
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.
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.
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.