How to solve it,this show as same letter as full array


#1

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


#2

j contains the indexes of your name found in text, so then we can use text[j] to get/retrieve the letter, which we push into our hits array


#3

yes, the problem has solved.
Thank you!