Ad
  • Custom User Avatar

    You forgot the 0

  • Custom User Avatar

    When I told you about overwritting the var you use in the loop, I meant the i var, normally you change its value in the last expression, see it here. While what you've done somehow works, it's not the normal way of doing it, and it seems confusing, you could use a better suited loop for that like while (note that it'll be still a nested loop and it won't work in this kata either).
    About mutating the input, yes, I was talking about arr, note that your code could be only a function amongst another functions and you're destroying the array, in functional programming that's very bad, and here in CW you'll find some katas where doing that changes the value of the expected results.

    About performance, well, I'm not so well versed about it to refer you to some source, try googling Big O notation.

  • Custom User Avatar

    @James171, that code doesn't work, and why overwrite the var you use in the loop? Mutating the input is also a bad practice, and if you fix those 2 things, your code also suffer of poor performance with long inputs, so you too, take a look at the tests cases, try to figure out a way for creating the output with a single loop (you have nested loops there because reduce is a loop-alike method). I can't tell you more without spoiling it, good luck.

    P.S.: this can help you check what your code does step by step.

  • Custom User Avatar

    @maurobono your code is highly inefficient. Try another approach, see the example tests and try to figure out a pattern, linear solutions can be achieved here.

  • Custom User Avatar

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

  • Custom User Avatar

    Without seeing your code we can only guess, but the kata works in Javascript (just tested it), so it must be a problem with your code.

  • Custom User Avatar

    Those are two separate tests. When there is nothing to log, nothing is shown, try console.log("Input value: '" + parens + "'")