Ad
  • Custom User Avatar

    Ah I think you were hitting the same problem as me! I also did a solution involving MUTATING the loop nodes. The rather unhelpful error message is coming from a test which calls your function TWICE on the same loop... now you know this you should be able to fix it!

  • Default User Avatar

    The submit test will run a second time ,you can console total to see it .

  • Default User Avatar

    I added a attribite on nodes at first,just like node.isVisit = node.isVisit || 1, to mark node is whether being visited.But I failed.At last I find out that the method you wrote will be run a second time ,maybe just like youMethod(node);return yourMethod(node);.So if you define a node.x on it,and use if(!node.x) to do the loop,probably you will get wrong answer without any wrong tips.It will only tell you that you answer is not expected.By knowing this,I finally solve this kata by adding attribite in a minimum loop time.Then I think maybe the author just dont want us to add anything to the nodes to solve the kata , just like the rabbit and the turtle .It's so funny.

  • Custom User Avatar

    if you mutate the original array, which you shouldn't be doing you may get different results

  • Default User Avatar

    I was trying using a Bubble sort to solve this case ,and I do not thing when ages are equals,but still couldn't pass it.Then I used console.log to see the origional array and the correct answer,found out that it did changed order when ages are equals sometimes which is different from the origional ones.