Stuck in JavaScript lection 22


#1

I dont know how to come through the lection 22.
Can someone help me with lection 22???

What is deet substrings in 22, i am gona find the 4th and 7th letter through
"wonderful day".substring(x, y)


#2

Hello @ajaxsurfer63507,

Please let's see what you've tried out. :slight_smile:


#3

I have tried to write "wonderful day".substring(4,7);
and that is wrong.


#4

Okay, you start counting from 0 for the first position/index, so you should have:

"wonderful day".substring(3,7);

#6

If i write exactly that, this is coming.
Oops, try again. Did you remember to take your .substring() from the string 'wonderful day'? Make sure to type your string exactly as shown!

And this is what they want me to do.
Find the 4th up to and including the 7th letter of the string "wonderful day".


#7

Please, show me your code after doing what I recommended.

Thank you.


#8

@bayoishola20 This also helped for me thanks! But if you count from zero should the last number not be six and not seven? :slight_smile:


#9

I also had this problem and I just reset the code after that just but back "wonderful day".substring(3,7); and you're good to go :wink:


#10

See illustration:

+---+---+---+---+---+---+---+---+---+
| W | O | N | D | E | R | F  | U | L|
+---+---+---+---+---+---+---+---+---+
  0   1   2   3   4   5   6    7  8

"string".substring(start,end);

Your end value is one step above the intended stop; whereas, start is exactly at start spot.

I hope this explains it. :slight_smile:


#11

OMG, thank you mate, i just paste it, and i was done! :smile:


#12

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