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.
This comment is hidden because it contains spoiler information about the solution
Hi guys!
I propose 1 more test to infeer if input parameters were changed (this way we get a more direct exposed information):
describe("Solution", function(){
let moves = ['up', 'left', 'right', 'left', 'left'];
let position = [0,0]
it("shouldn't change the input parameters", function(){
streetFighterSelection(fighters, position, moves);
assert.deepEqual(fighters, [["Ryu", "E.Honda", "Blanka", "Guile", "Balrog", "Vega"],
["Ken", "Chun Li", "Zangief", "Dhalsim", "Sagat", "M.Bison"]]);
assert.deepEqual(position, [0,0]);
assert.deepEqual(moves, ['up', 'left', 'right', 'left', 'left']);
});
});
[Sorry, don't now how to preserve code formatation]
I figured out the issue and fixed it.
The issue was if someone mutated the passed parameters the test would fail. So before calling the function I'm now cloning the parameters.
Interestingly, this is relevant to TypeScript version of the Kata and not relevant to its JavaScript version. Discovered it just now, after translating my JS solution to TS. In JS version I am mutating position. Mutating position in TS version results in random tests failure. After copying it to temp variable and using it, the test passed with the same logic.
There. Added a warning about not changing input data.
Are you sure that popping off moves is the right/best approach?