Ad
  • Default User Avatar

    Hi, I just tested your solution and it doesn't pass all the tests.

    The point here is, when you sometimes use a for loop to repeatedly perform an action, if the action is identical every single time then the parameter is not needed. However, as you may be aware, in most cases, the action performed is not identical.

    Say, for example, you wanted to console.log the numbers 1 to 10 on the screen. If you didn't pass the i parameter in, how can you possibly tell the computer to print an integer and increment by one every time? The only solution is to use the parameter i which by definition of your for loop increments by 1 every time:

    for (let i = 0; i < 10; i++) {
      console.log(i + 1); // Prints 1 to 10 by using the "i" parameter
    }
    

    Of course you could ignore the parameter i and introduce (and increment) an external variable, but the example above is the most direct and obvious solution.