Log it!


#1

CA is accepting my code, however as I haven't put my name in the sentence, it is just delivering the four letters that come after the only 'l' in the sentence.
Am I doing something wrong or does the example just not account for the fact that people may test it without their name in the text?

var text = "This is how it works you're young until you're not";

var myName = "lisa";

var hits = [];

for(var i = 0; i < text.length; i++){
if(text[i] === "l"){
for(var j = i; j < (i + myName.length); j++){
hits.push(text[j]);
}
}
}
if(hits.length === 0){
console.log("Your name wasn't found!");
} else {
console.log(hits);
}


#2

@lisa.wilson1111,
Your assumption is correct....


#3

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