What the correct result of "Search Text for Your Name"?


#1


Hello everybody.
I totally don't understand what the sense of this lesson?
First we mantion 3 variables. Then we look in the 'text' words which starts with our's name first letter. And after we just add more letters depands on how long our name is.

But, pasted large text and I don't see the result shows all the letters which start of my name's first letter.

So, I don't understand what the expected result of this lesson. Looks for me non-sensable.
Please, explain if possible.

Thanks in advance.
Sorry for not the smoothest english ever.



All correct.


/*jshint multistr:true */

var text = "Hello, I'm Igor. Nice to meet you! Hay, do you like puzzles, I do. Well, what you suggest? Below please find links to archived Q&A discussion for the Search Text for Your Name course. Search Text for Your Name Exercise 1.1: What you'll be building Exercise 1.2: Declare your variables Exercise 1.3: Your. Oops, try again. It looks like your second ‘for’ loop isn’t pushing values to the hits array. Make sure it’s working properly and that myName’s text appears somewhere in the text variable ";
var myName = "Igor";
var hits = [];

for (var i = 0; i < text.length; i++) {
    if (text[i] === myName[0]) {
        for (var j = i; j < (i + myName.length); j++) {
            hits.push(text[j]);
        }
    }
};

if (hits.length === 0) {
    console.log("Your name wasn't found!");
}
else {
    console.log(hits);
}


#2

the exercise assumes the only uppercase I will be your name. Which can be a flawed assumption, if that assumption is followed, it should only find your name

Otherwise you will have to continue building the program so it can only find your name


#3

Yep,
I have just read the objective of the exercise and I think I have followed it.
Still, thanks for reply, it's useful.


#4

in code at first the text was taken as a simple variable but in the if statement it is used as array. pls explain why this happens.


#5

please create a new topic with a good detailed question with code samples so someone can help you