Your "if" Statement


I keep getting syntax errors. I am working on the exercise mentioned above. Any help would be appreciated.

Replace this line with your code. 
<img src="//" width="590" height="246">


This code doesnt match with your link?!


Sorry about the issue and thanks for the feedback. I tried to take a screen shot - did not work to say the least. Here is a copy of my code so far and I am stuck.

var text = "Hey, my name is Warren. My middle name is Jay.";
var myName = "Warren";
var hits = [];
for (var i=0; i< myName.length[i]; i++) {
if (text[i]=== 'W') }

Keep getting syntax errors.



The hidden screenshot :wink::


Your problem is here:

if (text[i]=== 'W') }

You didn't finish all of the code, so it would raise an error for that, but the syntax error is because this brace is the wrong way around.

Do it like this:

/*jshint multistr:true */
var text = "Hey, my name is Warren. My middle name is Jay.";
var myName = "Warren";
var hits = [];
for (i = 0; i < text.length; i++){
    if (text[i] === "W") {


Thanks for the and getting the screenshot to work. I will try this and let you know - your help is appreciated.


Happy to help :)


That DID work! Thanks again.


No problem :slight_smile:


Btw: When you were supposed to declare the variables ( you should have put your name 3 times in there^^


Nope! It says:

Declare and set the following three variables: 01. text, and make it a string containing some text. Place your name in there a couple of times!

It does not say how many times specifically:

And it wouldn't affect the way the code works either, so as long as there is at least one instance of your name, the code will work and the exercise will pass :slight_smile:


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