Exercises Three through Six are not working


var text = "Hey, how are you doing? My name is Taylor.";
var myName = "Taylor";
var hits = ["Taylor"];
for ( var i = 0; i < text.length; i++){
if text[i] === 'T') {
for (var j = i; j < (i + myName.length); j++) {
if (hits.length === 0) {
console.log("Your name wasn't found!");
else {

I have completed the exercises to the specifications of the instructions and they all resulted in "syntax error", I need assistance in order to move forward onto the next section of this course.


I am slowly correcting the errors of my code.


on this line

if text[i] === 'T') {

you are missing an opening bracket

if (text[i] === 'T') {// you were missing an opening bracket here

also one more thing your hits array must be empty initially , it cannot have anything in it

var hits = ["Taylor"]; //should rather be var hits = [];

after you have corrected your current code and tested it you can take a look at this post to get an idea how to improve the push to hits
click here to post