Lesson 22: Substrings


#1


https://www.codecademy.com/en/courses/getting-started-v2/3/5?curriculum_id=506324b3a7dffd00020bf661

I have successfully completed this exercise, but I would like a more detailed understanding of how to complete the .substring process. It's a bit confusing. Thanks!



#2

So basically. When you create a string you should look at it like a coordinate plane. if you had the word "Raven" in your string it would be choosing an X value first starting at 0. 0=R, 1=a, 2=v, 3=e, and 4=n. Then once you choose an x value you will have to find a y. The y values start at 1 unlike the x values which starts at 0. Meaning 1=R, 2=a, and so on. Now if I wanted to make a substring of "Rav" with Raven I would start off at R as my x-value. Looking back I see it's the first letter making it 0. I then want the first 3 letters of the word. That means my y value should equal 3. In the end it should look like "Raven".substring(0,3).


#3

And this works every time (because it makes sense)?


#4

Not sure what you mean by that.


#5

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