Ad
  • Custom User Avatar

    My solution passes those. But fails one in the final run. (the first one)

  • Custom User Avatar

    Not an issue

  • Custom User Avatar

    "Boom, you failed to cut the wire"

    This is more riddle than coding challenge, and apparently I am bad at riddles. Can someone give me a hint?

    var wireCode = 1; // Find the wire.
    var Bomb = {
    CutTheWire: function(wireKey) {
    if (wireKey = 1) {
    return;
    }
    },
    Explode: function() { return }
    }
    Bomb.CutTheWire(wireCode);

  • Custom User Avatar

    Here are the ones I wrote if they help:

    const sqr = once((x) => { return x * x})
    Test.assertEquals(sqr(3), 9)
    Test.assertEquals(sqr(5), undefined)

    const add = once((a,b) => { return a + b })
    Test.assertEquals(add(1,2), 3)
    Test.assertEquals(add(5,9), undefined)
    Test.assertNotEquals(add(1,2), 3)

  • Custom User Avatar

    @osuushi yes, I realized my mistake a long time ago ;)

  • Custom User Avatar

    Your returned function doesn't return anything.

  • Custom User Avatar

    What does your resulting function return?

  • Custom User Avatar

    You're returning a function, but that function doesn't return anything.

  • Custom User Avatar

    Your solution only works if the function has one or zero arguments. The tests won't pass unless it can take any number of arguments.

  • Custom User Avatar

    Can someone provide an example of what a test looks like for this kata? Even just how to test the call in the kata description.

    Here's my code:

    function once(fn) {
    var executed = false;
    return function(variable) {
    if (!executed) {
    executed = true;
    fn(variable);
    }
    }
    }

  • Custom User Avatar

    Yep. Your function returns undefined and the tests pass it as the argument to your function again.
    Using push on undefined causes the error.

  • Custom User Avatar

    I've passed the kata. Just trying to understand the guts of the call stack.

    This is the line that causes the error:
    addWord(addWord(list, 'how are you'), 'goodbye');

    So I'm guessing that because the nested call to addWord hasn't returned 'goodbye' cannot be appended.

  • Custom User Avatar

    Why have you commented out the return statement? Your function should return the array after appending to it.

  • Custom User Avatar

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

  • Custom User Avatar
  • Loading more items...