Ad
  • Default User Avatar

    That's strange. I tried running this on a server I have running node 17.4, it prints "undefined" to my console. I see no way that it could print "found the needle at position 3" with the code that you've presented here.

  • Default User Avatar

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

  • Default User Avatar

    I would be surprised if this worked locally at all. It would only work locally if you were printing the value instead of returning it. As it is now, your return statement doesn't really do anything because it's only returning the value to the forEach function, and the forEach function doesn't really do anything with values returned to it.

  • Default User Avatar

    Ah, understood, thanks!
    Does it perhaps execute locally because locally I have the array as a global variable rather than in a test function?
    And hopefully my question is now marked with the spoiler tag - apologies, still getting the hang of Codewars.

  • Custom User Avatar

    Please mark your comment as spoiler if you have code in it.

    () => {} is a function. Your return statement only returns in that function. Thus your main function doesn't return anything.

  • Default User Avatar

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