you have the following string:
"hey jack its fun"
lets add the indexes:
h e y _ j a c k
0 1 2 3 4 5 6 7
i represented the space with a underscore.
so your name is at the following indexes:
4, 5, 6 and 7.
so then we start looping over the string, until we find the first letter of your name:
this condition is true when
so then we want to retrieve your name from the string, so we need another loop. First we give
a the value stored in
i contains the index of the first letter), why you set
1, i don't know.
then we need a way to stop our second for loop, we do this by using
i (which contains the first index) and myName.length (i (4) + myName.length (4))
This process would repeat if
jack was a second time in your string, but with a different value for i (the first loop continues after the second loop has finished)