Pushing letters to the array... help!



Currently getting "Oops, try again. Make sure you're pushing letters to the hits array!"

var text = "Hi my name is Carrie. What's your name?";
var myName = "Carrie";
var hits = [0];

for(var i = 0; i < text.length; i++); {
    if (text[i] === myName[0]) {
        for(var j = i; j < (i + myName.length); j++) {


Hello :slight_smile:

There are two problems in your code.

First one, your hits array should be initially empty -> var hits = [];.

Second one, semicolon after for loop:

for(var i = 0; i < text.length; i++); {

terminates it, so code inside this for is executed only once. You have to delete the semicolon.


Thank you so much!!! :sunny:


You're very welcome :panda_face:


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