5/7 - What's wrong with this please?


#1

var text = "Hey, how are you \
doing? Do you think Ben is \
a nice name? My name is Ben!";

var myName = "Ben";

var hits = [];

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


#2

@gigamaster60423,

for ([initialization]; [condition]; [final-expression]) {
   statement
}

In both of your FOR-loop condition's
you are using the greater-than-> operator, which should have been the less-than operator
like

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

Reference

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