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

Task 3 of 6 says the 10th character is a ' ', when it should be a 'b'? Is the 10th character not including a 0?

Update the variable of 'tenthCharacter' on about line 20, to get the tenth character of the string 'quick'.

You then have to put in quick.charAt(9), but shouldn't it be 10?

index.html
<!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 quickLength    = quick.length;
          var indexOfBrown = quick.indexOf("brown");
          var tenthCharacter = quick.charAt(9);
          var wordBrown = quick;
          var quickUpper = quick;
          var quickLower = quick;
    </script>
  </body>
</html>

2 Answers

Stone Preston
Stone Preston
42,016 Points

looking at the documentation on the charAt method, you can see that the charAt method takes an index as its argument.

indexes start at 0, so the 10th character is at index 9, since the first character is at index 0, the second is at index 1 etc.

quick.charAt(9)

is the 10th character. the 10th character (or the 9th index if you start counting at 0) is the space after the k in quick. You need to include the spaces when you count

Chris Shaw
Chris Shaw
26,676 Points

Hi Dan,

This challenge is a bit confusing because as Stone Preston mentioned character array's start at the zeroth index however this challenge is sneaky and is actually expecting the 10th character not the 10th index thus the answer is instead:

quick.charAt(10) // "b"

Got to love those cleaver teachers we have.