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 trial

JavaScript

Jason Larkin
Jason Larkin
13,970 Points

Trouble with Strings

I am trying to extract the substring 'brown' from the main string and although I have isolated the word, it won't let me pass. This is for the six-part strings code challenge in the JavaScript Foundations course. Can anyone please help me?

          var wordBrown = quick.substr(9,6);
Jason Larkin
Jason Larkin
13,970 Points

Thanks for your answer, but it won't let it pass in spite of the fact that it delivers the proper string.

1 Answer

Hi Jason,

The 1st argument to substr is the starting index. The index is zero based so it should be 10. The 2nd argument is how many characters. 'brown' is 5 characters.

Your code is extracting ' brown' with the space in front.