Until it reaches the end of text


#1

It says in the instructions the following:

Below your existing code, create a for loop that starts at 0, continues until it reaches the end of text, and increments by 1 each time. (This means it will check each character in the string.) There's no need to write anything between the {}s of your loop just yet.

In my code, I currently have the following:

/*jshint multistr:true */

text = "blah blah blah blah blah Fabio blah blah blah blah blah Fabio blah blah blah blah blah Fabio"
myName = "Fabio"
hits = [];

for (var i = 0,

I don't really know what to do, could someone please help me?


#2

Hey Fabio,

Essentially you need to write a for loop that iterates over each word in your 'text' string. Below is what that looks like. The var i = 0 sets the starting point for the loop, then i < text.length and i++ portions are saying: go through each word as long as the index of the word reached is less than the length of the entire content of the string. Once the loop reaches an index that is equal to the same number of words then it stops.

Let me know if that's clear.

for (var i = 0; i < text.length; i++) {
    
};

#3

Thank you so very much for information, this has helped a lot! :grinning: