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

JavaScript Foundations - Methods Code Challenge

Hey guys

So I'm currently doing the JavaScript Foundations - Methods code challenge. I get to part 4 and I'm coming across some problems. The question states

"Update the variable of 'wordBrown' on about line 21, to extract the substring of "brown" from the string 'quick'."

I have been declaring the following

var wordBrown = quick.subStr(9, 5);

And I get the following error:

You're missing the .substr() method. I am quite confused about the question and the error message that I am getting.

In the interim I will have a play around with the console and if I get the problem solved on my own I will let you all know.

Any advice would be greatly appreciated!

Thanks

Stu :)

2 Answers

Hello Stuart, the substr method is all lowercase. Also, remember that, in JavaScript, strings (and other kinds of objects) are zero-based, and spaces are considered characters too.

"The quick brown fox jumps over the lazy dog" has the 'b' at the 10th position starting at 0.

var wordBrown = quick.substr(10, 5);
Gerard Weppler
Gerard Weppler
4,357 Points

I get the position 10 but not understanding position 5

var wordBrown = quick.substr(10, 5);

Hey Victor,

I literally figured this out a few seconds after you posted this up!

I knew that it would be a silly error.

Thanks for that

Stu :)