5/7 topic


#1

/*jshint multistr:true */
var text = "Hi, my name is Austin. I love Austin.";
var myName = "Austin";
var hits = [];
for (numero = 0; numero > text.length; numero++) {
if (text[numero] === "A") {
for(j = numero; j < (numero + myName.length); j++) {
hits.push(text[j]);
}
}
}
HELP PLEASE IT DOESN'T WORK!!!!!


#2

Hey @austintbirds22,

Remember, numero is a variable. So you have to include var in there.

for (var numero = 0; numero > text.length; numero++) {

Same situation here:

To

for(var j = numero; j < (numero + myName.length); j++) {


#3

i think i'm missing something but can't see what... can someone help me? this is my code;

/*jshint multistr:true */

var text = "Hi my name is Lavinia. \
It is a comun name, right? Have you ever\
heared name Lavinia? I bet you did. I am \
too a Lavinia.";

var myName = "Lavinia";

var hits = [];

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

};

what is wrong?


#4

same problem.where am i wrong

/*jshint multistr:true */
var text = 'ho va ten vu duc dong' ;
var myName = 'dong';
var hits = [];
for (var i=0; i { if (text[i]==='d')
{ for (var j=i; j<(i+myName.length); j++; )
{ hits.push(text[j]); }
}
}


#5

Hey @ducdong94,

I want you to look at this closely:

You combined your for and if loop together, making a syntax problem.

Also:


The semi colon that's located at the very end, right after j++ must be deleted. :smiley:


#6

Hey @laviniaclim,

Look at this closely:

If i is lower than text.length, it should go upwards by one. Yours show that i is greater than text.length, and i should go upwards by one. Big difference there. Mostly because you don't have an end to it. So, you have to do the opposite comparator than you have right now.:smiley:


#7

var text = "Hey Lucas! Coding is supposed \
to be fun Lucas.";
var myName="Lucas";
var hits=[]
for ( var i=0; i > text.length; i++) {
if(text[0] === "L") {
for (var j=i; j > (i + myName.length); j++) {
hits.push("L")
}

}

};

Mine is also not working


#8

Got it, just needed to fill in values.


#9

thks ! now i know for sure where i was wrong:) thks again!


#10

Ok, but something is still wrong.
/*jshint multistr:true */
var text = "Hi, my name is Austin. I love Austin.";
var myName = "Austin";
var hits = [];
for (var numero = 0; numero >= text.length; numero++) {
if (text[numero] === "A") {
for(var j = numero; j < (numero + myName.length); j++) {
if (text[j] === myName[j-numero]) {
hits.push(text[j]);
}
}
}
}
Can you help me?


#11

Hey @austintbirds22,

You put another if statement there. :smiley:

You aren't supposed to put that, so it's what makes a problem.

Also remember to take out the } too. :smiley:


#12

var text = "Hello Noah, my name is Noah, what is yours?";
var myName = "Noah";
var hits = []

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

I don't understand where I have gone wrong. Please help.


#13

Hey @nanders,

text[i], for i is a property of text, not i === N ! :smiley:


#14

Thank you for helping me