5. Your second "for" loop - help


/*jshint multistr:true */
var text = "Her name is Katie \
Katie is a really good person.";
var myName = "Katie";
var hits = [];

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

Well.. I can't find the error and I also don't understand what "This loop will make sure each character of your name gets pushed to the final array." means. Please help me


The aim of program is to find the first letter of your name inside the string text,If it finds it then push all the letters of name to lists array.



if(text[i] === myName[i])

we loop over text, then to determine our name is present, we compare current character in text (text[i]) to see if it equals myName first character. i will change over time, while the condition should always check current character in text equals first character of your name (myName)


Oh ok thank you for helping me !


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.