Search Text for Name


“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.”

Dont understand the error message or .push( )

/*jshint multistr:true */

var text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum Katelyn has been the industry's standard dummy text ever Katelyn since the 1500s, when an unknown printer took a galley of type and scrambled it to make Katelyn a type specimen book.";

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

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


look at your first for loop condition, its incorrect, as a result your first for loop makes zero iterations, meaning: given the first for loop doesn’t run, .push() is never reached


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