6. Log it!


#1

hey I am having troubles on this can you tell me what im doing wrong

/*jshint multistr:true */

var text = "I like to eat food with Preston because Preston is really amazing!";

var myName = "Preston";

var hits = [];

for (var i = 0; i < text.length; i++){
if (text[i] === myName[0]) {
for (var j = i; j < i + myName.length; j++)
hits.push(text[j]);
}
}
console.log(hits)
if (hits.length is === 0) {
console.log("your name wasn't found!");
} else {
console.log(hits);
}


#2

@lightattheend,

for (var i = 0; i < text.length; i++){
    if (text[i] === myName[0]) {
        for (var j = i; j < i + myName.length; j++) {
            hits.push(text[j]); 
        }
    }
}
console.log(hits);
if (hits.length === 0) {
    console.log("your name wasn't found!");
} else {
    console.log(hits);
}