Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJ.C. Hiatt
9,393 PointsIs it (length, start) now?
When I run whole.substr(6, 5) I get World' just as you did, however for some reason when I run whole.substr(5,5) I get 'Worl' although I expected to get ' Wor'. Why is that? Has it changed from (start, length) to (length, start) since this video was filmed?
1 Answer
Matthew Orndoff
9,018 PointsHi J.C.
It's still (start, length), according to the MDN docs
str.substr(start[, length])
What you should be getting back is this:
whole.substr(5,5);
// " Worl"
So that's one space, and 4 characters. I think you might've gotten a little confused, it looks like you're expecting " Wor", which is only one space and 3 characters. What you're getting back is to be expected, you might just be accidentally overlooking the space at the beginning.
Hope that helps.