My loop prints the value of the result, instead of my name, when executed


Instead of printing "Chris" three times, my result is 15.
I'm not sure what my mistake is. I've tried looking over it multiple times.
Any help will be greatly appreciated.

My Code:

var text
var myName
var hits

var text = "Some random words like my name Chris, to test whether or not these\ things work or not. Hopefull they do, like my name which is Chris.\ Hopefull it will not be as frustrating as i imagine it could be. My name is Chris."

var myName = "Chris";

var hits = [];

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


If you are on exercise 5, then your code is working perfectly. If you want to see what is in the hits array then you can log it like this:

console.log("hits array: ", hits);

That should be coming up in the next exercise.


Thanks. I was going through my code so many times trying to figure it out.
I can finally progress lol.