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

    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.

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