Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

Nathaniel Quashie
Nathaniel Quashie
4,376 Points

[Coding Challenge help] Update the variable of 'tenthCharacter' on about line 20, to get the tenth character ....

<!DOCTYPE html> <html lang="en"> <head> <title> JavaScript Foundations: Strings</title> <style> html { background: #FAFAFA; font-family: sans-serif; } </style> </head> <body> <h1>JavaScript Foundations</h1> <h2>Strings: Methods</h2> <script> var quick = "The quick brown fox jumps over the lazy dog"; var tenthCharacter = quick.charAt(9);

</script>

</body> </html>

So basically its asking for the 10th character in the string assigned to the variable quick. Seeing as JS starts its count from 0, you'd think the answer would be "b" or quick.charAt(10)

but instead if you try that it'll show an error saying they expected an empty string or " " as the answer... but the " " is located at the 9th index...

I have the right answer, I just wanted to bring this (possible bug?) to the attention of teachers as this could be a confusing error for complete noobies.

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

Just copy the URL from your browser address bar when you're at the challenge's page, I will find my way there, or tell me the exact course > badge > challenge number.

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,440 Points

Well, the right answer is definitely var tenthCharacter = quick.charAt(9);, since index 9 is the 10th character and it is ' '. Space is the 10th character (from natural, intuitive human perspective), but human 10th character is indexed as 9 in most programming languages.

1 2 3 4 5 6 7 8 9 10
T h e   q u i c k