I have no idea what i am doing wrong


#1

/*jshint multistr:true */
for (var i = 0; i <= text.length; i++) {
if (text[i] === "A"){
for (var i = 0; i < myName.length; i++){}
}
}
var text = "Lorem ipsum Ashwin dolor sit amet, consectetur adipiscing elit. Aliquam consequat velit dui, quis aliquet metus convallis in. Phasellus a urna id dui rutrum convallis. Donec con Ashwin vallis ornare varius. Ashwin Proin efficitur nunc ut lectus sodales, et cursus urna feugiat. Vestibulum nec est libero. Nam ac commodo est, ut mollis leo. Duis nec arcu non nulla aliquet sagittis nec at libero. Nunc id mi placerat ipsum euismod tincidunt Ashwin vel a nulla. Nam condimentum semper enim vitae consectetur. Integer sed viverra urna. Aliquam erat volutpat.";
var myName = "Ashwin";
var hits = [];


#2

Hi,

i will give you here my code so you can see what are your mistakes and learn how to do it better.

/*jshint multistr:true */

var text = "Hey, how are you \
doing? My name is Emily.";
var myName = "Emily";
var hits = [];

for(var i = 0; i <= text.length; i++){
    if(text[i] === "E"){
        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);
}

KR
DooKoo