HI try to add a ;
at the end of all your variables.
I tried but it still isn’t working.
add one after the var myName
too you should remove the one after all your for loop stetement
for (statement1, statement2, statement3) ; <= this one
I tried that but the computer just froze. Do you think it could be a problem other than the code?
can you post your code?
here how to format it
/*jshint multistr:true */
var text=“Hi, my name is Wayne. I’m 29 years old. I come from Australia. Wayne is the nickname that I gave myself”;
var myName=“Wayne”;
var hits=;
for(var i=0;i<text.length;i++){
if(text[i]===‘W’){
for(var j=i;j<i+myName.length;i++)
{hits.push(text[j]);}
}
};
here
for(var i=0;iif(text[i]==='W')
you mising peace of yout for loop here how it should be
for (var i = 0; i < text.length; i++) {
if(text[i]==='W') {
teh smae to your second for loop
for(var j=i;j{hits.push(text[j]);}
should be like that
for (var i = 0; i < text.length; i++) { #open the first for loop
if(text[i]==='W') { #open the if statemnt
for (var j=i; j < i + myName.length; j++){ #open the second for loop
hits.push(text[j]);
}#close the second for loop
}#close the fi statement
}#close the first for loop
the error come frome the second for loop you inscresed i++
instead of j++
var text = “blah blah blah Israel blah blah blah Israel hahaha blah lah”;
var myName = “Israel”;
var hits = ;
for (var i = 0; i < text.length; i++) {
if (text[i] === “I”) {
for (var j = i; j < (i + myName.length) ; j++) {
hits.push([j]);
}
}
}
console.log(hits)
when I log it out, it comes out as numbers, not the characters. Somebody help me plox
Hi you should push() inside hits text[j] like that
hits.push(text[j])
Thanks!!! It works now!
I believe it’s the other way around. You should open your eyes and read my comment in it’s entirety before replying.
`/*jshint multistr:true */
var text =“Whatever I want to put here!”;
var myName =“Robert Mack”;
var hits = ;
for(var i = 0; i < text.length; i++){
if(text[i] === ‘R’){
for(var j = i; j < i + myName.length; j++){
hits.push(text[j]);
}
}
}`
Can’t Figure it out!
figured it out!
Now my question is to fix it and let me continue was I changed this:
if(text[i] === ‘R’)
to this:
if(text[i] ===‘r’)
Why is that? In a previous lesson it wouldn’t let me continue if I used a lower case r but now it wanted me to change it to a lower case r?
for (i = 0; i < text.length; i++) {
if (“G” === text[0]) {
for (j = i; j < (i + myName.length); j++) {
hits.push(text[j]);
}
}
};
My name in the text is Greg so thats why i’m looking for a uppercase “G”.
"I’m getting the error “Oops, try again. It looks like your second’for’ loop is’t pushing values to the hits arrary. Make sure it’s working properly and that myNmae’s text appears somewhere in the text variable.”
I have looked down this post for the most part tonight through frustrated eyes and i believe i have done it all right, but obviously not. Can someone please help me.
Thank you in advance!
for (i = 0; i < text.length; i++) {
if (“G” === text**[i]**) {
for (j = i; j < (i + myName.length); j++) {
hits.push(text[j]);
}
}
};
Figured it out…
if (“G” === text[0])
can someone help me i have done this so many time i
/*jshint multistr:true */
var text = “■■■■ Word”
var myName = “Ibrahim”;
var hits =;
for (var i = 0; i < text.length; i++); {
if (text[i] === ‘I’) {
console.log(myName)
for(j = i; j < (i + myName.length); j++) {
hits.push(text[j]);
}
}
}
Oops, try again. It looks like your second ‘for’ loop isn’t pushing values to the hits array. Make sure it’s working properly and that myName’s text appears somewhere in the text variable.
Hi you should have your name write inside the variable text at least once.
can someone help me with this
var text = “Hey, how are you
doing? My name is ibrahim.”;
var myName = “Ibrahim”;
var hits =[i];
for (var i = 0; i < text.length; i++); {
if (text[i] === ‘I’) {
console.log(myName)
for (var j=i; j<i + myName.length; j++){
hits.push(text[j]);
}
}
}
console.log(hits);
Oops, try again. Make sure you’re pushing letters to the hits array
Hi first the variable hits
var hits =[i];
Should be a empty array like that
var hits = [],
Then at your for loop
s remove the semicolon at the and of statement
for (var i = 0; i < text.length; i++); <== this one
for (var j=i; j hits.push(text[j]); <== this one too
Then inside your second for loop
for (var j=i; j hits.push(text[j]);
Its missing the second and third statement and the hits.push(text[j]) should be inside the for loop like that
for (statement, statement2, statement3) {
hits.push(text[j])
}