Ad
  • 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 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.