Anybody up for a late nighter?


#1

I can't seem to figure it out it. it's 11:23

var text = "blah blah ralph sanchez,\ blah blah blah ralph sanchez \ blah blah blah blah ralph sanchez blah blah blah blah blah \ blah blah blah blah blah ralph sanchez blah \ blah blah blah blah blah."

var myName = "ralph sanchez";
var hits = [];

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

#2

@alexmisanchez,

Change your second FOR-loop into

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

by removing ; } else


#3

i know your busy trying to help everybody else but i'm still having issues. t
for (var i=0; i if (text[i] === "r") {
for(var j=i; j < (myName.length + i); i++) {
hits.push(text[j]);
} else {
}
}
};


#4

@alexmisanchez,

var text = "blah blah ralph sanchez,"+
    " blah blah blah ralph sanchez "+
    " blah blah blah blah ralph sanchez blah blah blah blah blah "+
    " blah blah blah blah blah ralph sanchez blah "+
    " blah blah blah blah blah."

var myName = "ralph sanchez";
var hits = [];

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

#5

I was up doing this at 5am... stop me.


#6

@arcjumper48567,
Take a break....

the for-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for

the while-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while

the do-while-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while