Typo in JavaScript "Search Text for Your Name" section "Victory"


On the page linked below, the text reads that if the name is "Eric," and the string being searched contained both "Eric" and "Eddie" the hits array would be ["E","r","i","c","E","d","d","i","e"]. This is incorrect.
In actuality, the array should look like ["E","r","i","c","E","d","d","i"], not containing the final "e" in "Eddie."

I do not know how to submit an actual bug report, so if there is an official way of going about that, please post a link in the comments.

--It is worth noting that the code provided is not my own. It is the code supplied in the first section of this activity with the name "Eddie" added in a few places within the text array.

Link here

/*jshint multistr:true */

text = "Blah blah Eddie blah blah blah blah Eric \
blah blah blah Eric blah blah Eric blah blah \
blah blah Eddie 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++) {

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


Hello @eisem,

You are right, of course, but this is just a quick way to explain the shortcomings of this code to beginner programmers.


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