Errata in excercise explanation


#1



https://www.codecademy.com/courses/javascript-beginner-en-XEDZA/0/7?curriculum_id=506324b3a7dffd00020bf661


The explanation says: "[...]for instance, if the paragraph contains both "Eric" and "Eddie", we'll see this in our hits array:
['E','r','i','c','E','d','d','i','e'];"

but it will just give
['E','r','i','c','E','d','d','i'];

since the second FOR will stop when it reaches the myName.length, which in case of "Eric", is 4. Hence it will show just the first 4 characters it finds.

If you try the code it will show it.


/*jshint multistr:true */

text = "Blah blah blah blah blah blah Eric \
blah blah blah Eddie blah blah Eric blah blah \
blah blah blah blah blah Eric";

var myName = "Eric";
var hits = [];

// Look for "E" in the text
for(var i = 0; i < text.length; i++) {
    if (text[i] === "E") {
        // If we find it, add characters up to
        // the length of my name to the array
        for(var j = i; j < (myName.length + i); j++) {
            hits.push(text[j]);
        }
    }
}

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


#2

Thank you for reporting the problem, we recognise this is a bug, however as it does not prevent users from passing the lesson and this is one of the older courses it is unlikely this bug will be fixed. Thank you for taking the time to inform us though, we would like everything to be fixed just as much as you would!