Isn't pushing values to the hits array. WHY?!?


After spending hours trying to figure out the problem myself to no avail I decided to go back to the "1.What you'll be building" lesson and copied the code to see if it would work. It didn't. Am I missing anything. Please help!

/*jshint multistr:true */
text = "It was the best of times, it was the worst of times, it was the age\ of wisdom, it was the age of foolishness, it was the epoch of belief it was\ the epoch of incredulity, it was the season of light, it was the season of\ darkness, it was the spring of hope, it was the winter of despair." ;

var myName = "Dicke";
var hits = [];

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

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.


According to instructions text should contain value of myName, at least one.

Add "Dicke" to the text.


HAHAHA geez! Thank you so much.


You're very welcome :wink:


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