6.Log it & 7.Victory are correct, but are they really? Help


#1

I've completed these two exercise and got it correct however i feel that it isn't. After submitting my code in , the results in the console display B's only. But from what i seen they're supposedly suppose to display the myName variable with a comma in between each letter. To be honest i completed this section without really understanding anything but somehow i managed to make it to the end. Could anyone please look through my code and see if anything is wrong or if the display of [ 'B', 'B', 'B' ] is supposed to be there. Thank you

/*jshint multistr:true */

var text = "Bob is cool but are you?";
var myName = "Bob";
var hits = [];

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

}}

if(hits.length === 0) {
console.log("Your name wasn't found!");
}else {
console.log(hits);
}


#2

@tagrunner54733,

You will have to change

hits.push(text[i]);

into

hits.push(text[j]);

#3

Thank you very much !