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

    Woohoo! My first Kata! Don't overthink it guys! Think about the problem, then code! Trust me! You'll be shocked at how much you may have overthought it!

  • Default User Avatar

    I was attempting to accomplish this Kata without using a for loop, but cant seem to think of another way of doing it. After giving the for loop a go I keep running into the error "TypeError: 0 is not iterable" now im assuming that this has something to do with my loop, but i cant seem to see where i went wrong. Any guidance on where i might have messed up would be great, and if maybe you could give me another possible route to take to accomplish a correct answer without using a for loop would be awesome. Thanks for any help

  • Default User Avatar

    Awesome man thanks for your help.

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

  • Default User Avatar

    Hello, I keep running into this problem (expected 'found the needle at position 5' to equal 'found the needle at position 3') Im unsure where I went wrong. According to my code this would be the correct answer. Any guidance?