Ad
  • Custom User Avatar
  • Default User Avatar

    In the description says that the team always plays 10 matches, but is secure to use a loop.

  • Custom User Avatar

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

  • Custom User Avatar

    A loop is required, simply because you don't know how long the array games is. A solution without a loop isn't possible.
    Edit: Since there are always 10 games, you don't need a loop.

    The error comes from this line: let [i] = 0, which tries to handle 0 as if it were an array. You should use let i = 0 instead.

    Here are a few tips:

    • Use == or === when comparing values
    • You can access an index of an array by using []. So index 1 of array "arr" can be accessed with arr[1].
    • Your code has to use the games variable
  • Custom User Avatar

    Your function needs to accept an argument, which you then work with.

    It should look like this:

    function findNeedle(haystack) {
      // your code here
    }
    

    Currently, your function just does the same thing over and over again and is ignoring the input. You need to use the argument instead of your position array.