Eddie, Eric


Hi all,

In the lesson "Victory!", it says the following:

You've done it! Nice work.

Now, as we mentioned, this system isn't perfect. For instance, if the paragraph contains both "Eric" and "Eddie", we'll see this in our hits array:


But why would it say "Eddie"?

Surely the code would merely just say "Eddi" because in the code, it is searching for the first letter and then after printing the next 3 letters?

I've tested this with my code and the example code and I see no light. Please enlighten me :slightly_smiling:


So, i tested what you said. and this was the output:

And Eddie became Eddi, can i see your code?

/*jshint multistr:true */

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

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 {

According to the example code, I tested this as you can see above.
This is the output:

[ 'E', 'r', 'i', 'c', 'E', 'r', 'i', 'c', 'E', 'r', 'i', 'c', 'E', 'd', 'd', 'i' ]

What I'm saying, is that I believe the final lesson in this section is wrong, by saying that it will print out "'E','d','d','i','e'". I think this should be corrected to showing "'E','d','d','i','" instead. My code is basically exactly the same as this, there is no problems there.


Now i understand, i believe this reported as a bug already, but i hope you can understand this doesn't have a high priority.

Thank you for letting us know :slightly_smiling: