Search Text for Your Name 5/7 What am I missing?


#1

var text = "Whitney is really good at math. Whitney likes to read."
var myName = "Whitney"
var hits = []

for (var i = 0; i < text.length; i++);
if (text[i] === 'W') {
for (var j = i; j < i + myName.length; j++)
hits.push(text[j]);
}
/*jshint multistr:true */


#2

@roxybyu,
Be carefull in using a semi-colon-;
as for the Javascript Interpreter the semi-colon-; is an End-of-Statement indicator.

The structure of your code should look like

for ([initialization]; [condition]; [final-expression]) {
   if ( condition) {
       for ([initialization]; [condition]; [final-expression])
            hits.push( text[j] ) 
       }
    }
 }