6.log it



var text = "ashish how are you";
var myName = "ashish";
var hits =[];
for (var i = 0; i<=text.length; i++){
if(text[i] === "a"){
for(var j = i; j < myName.length + i; j++){

       if(hits.length === 0){
           console.log("your name wasnt found");

i am not getting the required output instead some numbers are coming out
please let me know the mistake
also i didnt understand the myName.length +i part and the subsequent push() part


Hi this line


Inside push() you should put text[j] instead of [j] and

i didnt understand the myName.length +i part

You Can Read more about It here


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