What's wrong with my code?


#1

var text = "text test text";
var myName ="Emily"
var hits = [];
for(var i = 0; i < text.length; i++){
console.log(i)
}
// Assuming your name starts with 'E'
if (text[i] === 'E') {
for (var j = i; j === i + myName.length; i++) {
hits.push("emily");
}
}
}

what's wrong with my code??


Your second “for” loop | It looks like your second ‘for’ loop isn’t pushing values to the hits array
#2

if (text[i] === 'E') {
for (var j = i; j === i + myName.length; i++) {
hits.push("emily");
}
}
}   //remove it, you added extra }

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.