What is wrong with my code?


#1

Hi, I can't figure out what is wrong with my code. Could someone please tell me?

/*jshint multistr:true */
var text = "Minecraft is awsome!";
var myName = "Kolten";
var hits = [];
for (var i = 0; i >= text.length; i += 1) {
if(text[i] === 'K') {
for (var j = i; i >= hits.push(text[y]); i +=1)
}
}


#2

Your for (var j = i; i >= hits.push(text[y]); i +=1) is not written correctly you need to specify the length of where you want your loop to stop it should be written as

for(j=i; j<myName.length+i; j++){
            hits.push(text[i]);
        }

you are also missing {} for the 2nd for loop


#3

var text = "basdhsbfbdjd, Terrell, udgbahbf, Terrell,\
sfuygsfdg, dgsuhagfbhb, ahsbjksb, sdajkfi, gfdhhhasb, fjidrne,\
Terrell, djfieni, dkjfioj, jsdfojf, fjdiotj, jfdi9aj";
var myName = "Terrell"
var hits = []
for(var i = 0; i < text.length; i++); {
if(text[i] === "T")
{
for(var j = i; j < (myName.length + i); j++) {
hits.push(text[j]);
}
}
}
Can you tell me what's wrong with my code?


#4

Put semicolons after defining variables.
AND
Take out the semicolon after the first For loop condition.
@objectsurfer52115