Please help on #22. Substrings



I have been having problems with this piece of code.

I was wondering if you could help me??/

w o n d e r f u l D a y
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
0 1 2 3 4 5 6 7 8 9 10 11 12
"wonderfulday".substring(5, 7);

Thank you!!


You'll need to start by identifying what it is doing differently from what you want it to be doing


It keeps on saying...

" It looks like 'W' on line 1 was not defined before it was used. This means either you need to define it, 'W' is spelled incorrectly or you need quotes around 'W'. "

I don't get what it means!!!


I don't see any uppercase W in what you said is your code. I also don't see any error messages like that in exercise 22. I can't figure out what you're currently doing based on what you've said, I can't reproduce what you describe. Are you sure that you've gathered and presented all relevant information? It isn't adding up.

But have you considered what that error message is saying, how it relates to the exercise and your code? It seems to say that you're using a variable that you haven't created. And it seems to say that the name of the variable is W. So what are you doing with W in your code? Any W's should be part of the string here, and as the error message says, strings have to be quoted. There also shouldn't be any upper-case W's, the string is after all: "wonderful day"

Is the error message from codecademy at all? Where are you running your code? And which code are you using? (make sure it's intact and can be copied to produce the same thing as you describe)


I need Help on this it just wont work, I just don't know what to do.



"wonderful day".substring(3, 7); because the 4th letter is on the 3rd place.
Counting starts from 0.
w - 0
o - 1
n - 2
d - 3
e - 4 and so on.


I had problems with this one but now I got it right. Thank you guys. I had it so that I wrote "Wonderful day" but it was suppoused to be "wonderful day".


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