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 Strings Methods

Arvid Keskitalo
Arvid Keskitalo
23,406 Points

Q about charAt

I am at the challenge task 3 about JavaScript, where I am supposed to find the 10th character in the .quick string. The 10th char in the string is the b in the word 'brown'. I tried to solve the task doing this: var .....= quick.charAt(10); The challenge console returned "Bummer! Was expecting a ' ', got a 'b'.

"Isn't it exactly what should happen?

2 Answers

Stone Preston
Stone Preston
42,016 Points

strings are indexed starting at 0, so the 10th character is the 9th index since you start counting from zero.

the 10th character is at the 9th index, which is a space

try

var tenthCharacter = quick.charAt(9);

see the documentation on charAt() for more information on the function.

Arvid Keskitalo
Arvid Keskitalo
23,406 Points

of course, you are right, thanks, Stone !