I have the following code:
for (i = 0; i < 3; i++){ //big loop
console.log("Start of round" + i)
for (s = 0; s < 5000; s++){ //small loop aka delay loop
console.log("End of round" + i);
}
s = 0; //reset
}
Just to begin with - I know that there are other ways to solve this. Thing is, I am trying to learn further about loops so I picked this example, and please tell me where I am wrong.
so I have a loop that is supposed to run itself 3 times. and each time it runs itself, there is a loop that is supposed to delay the proceeding. Problem is, the delay stops happening at the 2nd and 3rd times.
Here is what I think that is supposed to happen
1) first i = 0, proceed with loop
2)Delay further proceeding with a loop inside
3)when delaying loop is over, reset the s var of the small loop, so it would run itself again when i = 1; and the bigger loop will start again
4) big loop starts again as i = 1; so proceed, run the delaying loop once again, because we have reset var s in the last time.
5) repeat when i = 2
What is it that I am missing here? I would like a deeper knowledge about javascript loops. thank you.