Using the .push() method


#1

/*jshint multistr:true */
var text = "Hey, guys I just got here! \
It's nice to meet you";
var myName = "Tochukwu Obafemi Marque Uzoije";
var hits = [];

for (var i = 0; i < text.length; i++) {
if (text[i] === "T") {
for (var j = i; j < (myName.length + i); j++) {
hits.push(text[j]);
}
}
}

This keeps popping up:
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.
Please help me. I have no idea what I am doing wrong.


#2

For the purposes of the this exercise, it would be simpler if you use just your shortened name (Tochukwu), and as the exercise advises, be sure that it appears at least once in the text. Your name is nowhere to be found, at present.


#3

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