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 trialNathaniel 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.
Nathaniel Quashie
4,376 PointsHow do you link challenges?
Maciej Czuchnowski
36,441 PointsJust 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
36,441 PointsWell, 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.
Chris Chambers
5,634 Points1 2 3 4 5 6 7 8 9 10
T h e q u i c k
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsPlease link the challenge.