Second loop 5/7 Please someone help me!


/*jshint multistr:true */
var text = "Hey darling How was\
your day?";
var myName = "Ricky";
var hits = [];
for (var i = 0; i < text.length; i++){
if (text[i] === myName[i]){
for(var j = i; j < i + myName.length; j++){


Try to compare statment if with the first letter in myName:

if (text[i] === 'R') {

And type in the very end:


It should work


If you call as:


it will give you:

Happy New Year 'R', 'i', 'c', 'k', 'y' !

That is already good, but

you can try also to call myName in more clear way with orders of hits:

console.log("Happy New Year" + " " + hits[0] + hits[1] + hits[2] + hits[3] + hits[4] + "!");

That will type myName clear:

Happy New Year Ricky!



Call me ignorant, but the reason you get no hits is because your name is never actually said in the text. In order to find your name, the text has to contain your name. Otherwise your just searching for the amount of times "R", "i", "c", "k" and "y" shows up in the text. But won't find your name because an "i" never follows an uppercase "R" and a "c" and "k" are never even in the text.

At least, that is the way that I understand how this works.


@o_k_s_a_n_a @eagernoobcoder Thank you! For y'all's help I replace the variable myName with "R", console.log it and add my name into the text and it ran like a champ. :smile: