Ad
  • Custom User Avatar

    So I wasn't the only one who had the idea to make a Kata for this after watching that video!

  • Custom User Avatar

    I love this one, the concept of filtered searches has many applications in real software!

  • Custom User Avatar

    You don't even need the list(input_), it can just be input_ because strings already behave the same as lists!

  • Custom User Avatar

    Looking back two years later, I realize my mistake. Thanks for this!

  • Custom User Avatar

    Thanks for letting us know, I guess?

  • Custom User Avatar

    Oh my lord! There's.. so much.

  • Custom User Avatar

    Your code wasn't returning an array.

    You get a similar error with the initial code:

    function anagrams(word, words) {
    }
    

    The testing part assumes your function returns an array and tries to sort it, hence the error.

  • Custom User Avatar

    It was coming because instead of return statement I was printing the output using console.log(). It has nothing to do with sorting cause I was not using any sort array method. The code had only 30 lines of code and it was pointing error at lines 63 and 88, How is it even possible.

  • Custom User Avatar

    Add print or put in your code, check where it is failing (it's in the line 7).

  • Default User Avatar

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

  • Custom User Avatar

    ('dan', not 'kyu' ;p )

  • Custom User Avatar

    it apparently comes from your code: you're trying to sort an array that, at some point in the executions, isn't actully an array anymore.

  • Custom User Avatar

    Anyone know why I am seeing this.

    TypeError: Cannot read property 'sort' of undefined
    at testAnagrams
    at /home/codewarrior/index.js:63:13
    at /home/codewarrior/index.js:88:5
    at Object.handleError

    STDERR
    /runner/frameworks/javascript/cw-2.js:237
    throw ex;
    ^

    TypeError: Cannot read property 'sort' of undefined
    at testAnagrams (/home/codewarrior/index.js:56:18)
    at /home/codewarrior/index.js:63:13
    at /home/codewarrior/index.js:88:5
    at Object.handleError (/runner/frameworks/javascript/cw-2.js:233:11)
    at Object. (/home/codewarrior/index.js:3:6)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at [eval]:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at Object.runInThisContext (vm.js:139:38)
    at Object. ([eval]-wrapper:6:22)

  • Custom User Avatar

    You don't know anything you're only at 1 Kyu!

    In all seriousness, I understand what you mean. I looked at the other (top) answers and, as always, they're more concise and optimized. This is just the way I first thought of doing it.

  • Custom User Avatar

    Marked as spoiler.

    This is a very bad approach, actually. There are way better ways to handle this, without any dict. So providing this is just inviting other users to lazyness... ;p

  • Loading more items...