Ad
  • Default User Avatar

    This is too easy for 5 kyu, solved it in 3 minutes

  • 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

    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)