I have no idea why am I getting the Oops


#1

Oops, try again. It looks like your second 'for' loop isn't pushing values to the hits array. Make sure it's working properly and that myName's text appears somewhere in the text variable

var text = "this report examines alternative paths that a war between the United States and China might take, losses and other effects on both sides, preparations that the United States should make";
var myName = "China";
var hits = [];
for (i=0; i < text.lenght; i++) {
    if (text[i] === "C") {
        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);
};

I have no idea why am I getting the same Oops.. please if someone knows


#2

This is a typo that is a deal breaker.


#3

Thank you so much! I thought I am going crazy


#4

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