Ad
  • Custom 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
  • Custom User Avatar

    You were mutating the input. Now it shouldn't matter anymore.

  • Custom User Avatar

    This Kata is broken. For the random test it says:

    expected [ ... ] to deeply equal []

    Language: JS

  • Custom User Avatar

    Tell us your language. Help us help you!

    Insufficient data. Closing.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    Why does it say 'Value is not what was expected' with no explanation on the last test? What is expected there?

  • Custom User Avatar
      it('Handles multiple reassignments', () => {
        const typed = typedObject({ a: Array, b: String, c: Set });
        const length = Object.keys(typed).length;
        
        Object.keys(typed).forEach((key) => {
          for (let i = 0; i <= length; i++) {
            typed[key] = i;
          }
        });
        
        assert.deepEqual(typed.a, [length]);
        assert.deepEqual(typed.b, `${length}`);
        assert.deepEqual(typed.c, new Set([length]))
      });
    

    This test in the test fixture assumes that every key is already set in the typed object before any assignment, which is different from the default behaviour of object (obviously, keys that are not set yet will not appear in Object.keys). This behaviour is not mentioned anywhere, and probably should be changed.

  • Custom User Avatar

    The value it returns is b, of course, but the reference it returns is a. This matters if a is an object or a property of one.

    I can't tell you offhand why your solution isn't working; possibly the mechanism is different within a setter. But, frankly, I think that's your problem. If I knew, I would gladly tell you, but seeing as I don't, I'm not making your problem mine. Both Alex' and my solution handle this correctly, as far as I can see, so it's not impossible.

  • Custom User Avatar

    Not sure how this would be possible, I tried to return the expression itself but that doesn't work.
    Also, a = b returns b and not undefined, or am I missing something?

  • Custom User Avatar

    Fixed the description.

  • Custom User Avatar

    a = b should return a ( with its new value ) in JS. The reference solution doesn't seem to do this and I haven't checked if this is tested. Existing programs sometimes rely on this; it is not good practice to return undefined for this expression even if the side effect is handled correctly.

  • Custom User Avatar

    Description still doesn't specify what the initial values in a new typedObject shall ( or can ) be.

  • Loading more items...