In String Practice #23 I keep getting the error message "You have selected the wrong substring in January" although I have chosen the correct substring "//console.log "January" substring (0,2))


#1


Replace this line with your code.


#2

Hi Salli,

Please use the edit button to improve your question. The template will help you with that.


#3

I have tried to edit the code referenced above many times but it will not work and I cannot skip over it and progress.


#4

//console.log("January".substring(0,2));


#5

Don't worry about the code in the exercise just yet.

It will help people understand your question, if first, you edit your original question here in this forum.

Add a link to the exercise. Replace the line that says "Replace this line with your code" with the code that you have tried in the exercise.

//console.log("January".substring(0,2));

If that is the code that you have used, then there is a problem because you have made it a comment by adding // at the beginning. That tells the JavaScript interpreter to ignore that line.


#6

Thanks I got it to work. However I am a little confused by the "0" position. For the word "January" the J is in the zero spot but a=1 and n=2 but it seems like n must =3. Please explain.


#7

You are correct that:
0 : J
1 : a
2 : n
3 : u

substring works like this:

.substring(starting character, up to but not including the end character)


#8

So why does it not accept
"January".substring(0,3);
?


#9

Could you give me a screen shot showing that code not being accepted please?


#10

Here it is. I have tried retyping the January line, and different start and end position numbers, all with the same result. Am I missing seeing a mistake in what I entered?

Thanks for following up.


#11

I like solving problems :wink:

The problem there is that you've missed a bit of the instructions. They have asked you to print out the substrings but you haven't yet.


#12

Sorry for disturbing you, but I have the same problem. I've printed substrings out, you can see it in interpreter, but i still can't go further because of "error"


#13

Solved))) it was about lower case in "jan" instead of "Jan" ))


#14

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