Someone help. 5/7 Search Text for Your Name


#1

/*jshint multistr:true */

var text = " ebebvudvsuavcsvcgsvgvcgsv ecybbaylbcycyubcb chbyciasbcsbsbs ckncciubebcuib Dylan bfieufybfsb Dylan fbyibvysbiyvbyudvbvb byivcbir udbvyib bvydusbvyu Dylan"
var myName = "Dylan"
var hits = []
for(var i=0; i < myName.length; i++){
if (text[i] === 'D'){
for(var j = i; j < i + myName.length; j++) {
hits.push(myName)
}
}
}


#2

You need to push each individual letter of your name that you find, not the name itself. Just push text[j], and it will work correctly.


#3

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. @cadecodes Still doesn't work, got this error.


#4

var text = " ebebvudvsuavcsvcgsvgvcgsv ecybbaylbcycyubcb chbyciasbcsbsbs ckncciubebcuib Dylan bfieufybfsb Dylan fbyibvysbiyvbyudvbvb byivcbir udbvyib bvydusbvyu Dylan"
var myName = "Dylan"
var hits = []
for(var i=0; i < myName.length; i++){
if (text[i] === myName[0]){
for(var j = i; j < ( myName.length + i) ; j++) {
hits.push(text[j]);
}
}
}