FOR LOOP question. (the variable 'i' is not used

Please examine this code:

function talk () {
	let speech = '';
  for (let i = 0; i < 10000; i++) {
    speech += 'blah ';
  }
  console.log(speech);
}

talk();

My question is, why does it logs 10,000 blah when the variable i is not used? I’m confused.
How I understand this code is that speech += 'blah ’ is just equal to speech = speech + blah which means the variable speech is undefined and it just adds the string blah which will then log only 1 blah . I don’t see where the variable i is used. Please enlighten me.

I guess I read that wrong .
the i is used for iteration counts actually …
that means the loop ( speech will add a ‘blah ’ for i starting from zero and up to the point value of i passes 10000 ;
i++ means that we are incrementin’ the value of i (in each turn) so that it does not becomes an infinite loop.
the i is actually a dummy variable that keeps the track of no. of times your loop is going on and has the ending conditions as well .
you can mention again if you do not understand something
Cheers!

The variable i is used by the for loop, but you can think of it as a good byproduct of the for loop
and use it inside it however you want. like over iterating and loggin the elements of the array.
Instead of declaring one more variable to use

No, speech is not undefined. You defined speech as being equal to ''. If speech was truly undefined than after the first loop speech would be equal to 'undefinedblah'.