I'm trying to understand this code :
var text = "Hi, my name is Tyler. How are you?";
var myName = "Tyler";
var hits = [];
for (i = 0; i<= text.length; i++) {
if (text[i] === "T") {
for (j = i; j = (i + myName.length); j++) {
hits.push(i);
}
}
}
What does text[i] actually mean? To me, it appears to be saying "find the i element inside the text array". I don't understand this for two reasons. The first one is that the i element is not defined as anything. Is it saying to search every element in the text "array" until it matches T, which is the first letter of my name? And second, why is it representing text as an array when it is just a string? Doesn't the [ ] brackets after text mean it is referring to text as an array?
I'm sorry if this question didn't really make sense, but I just feel so confused by it all! Thanks in advance for anyone who can answer this for me!