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 Arrays Getting and Setting

Brian CI
Brian CI
28,971 Points

On about line 18, set the 31st element in 'myArray' to the word 'treehouse'.

Is there a bug in this challenge? I changed nothing in the first task yet trying to complete the third one causes it to fail.

Oops! It looks like Task 1 is no longer passing.

<!DOCTYPE html>
<html lang="en">
  <head>
    <title> JavaScript Foundations: Arrays</title>
    <style>
      html {
        background: #FAFAFA;
        font-family: sans-serif;
      }
    </style>
  </head>
  <body>
    <h1>JavaScript Foundations</h1>
    <h2>Arrays: Getting and Setting</h2>
    <script>
      var myArray = ["sugar", "rush", "fix", "it", 3.14, 42];
      var thirdElementInArray = myArray[2];
      var myArray[30] = "treehouse";

    </script>
  </body>
</html>

6 Answers

Try submitting it without the var keyword like below. This will add it to the existing array

myArray[30] = "treehouse";
Rachel Foster
Rachel Foster
6,641 Points

When I do this, I get: "Bummer! The 'myArray' length is 6 not 31."

Brian CI
Brian CI
28,971 Points

D'oh. I should have seen that :(

Jason Mc Dermott
Jason Mc Dermott
11,496 Points

I've put the answer in and it keeps changing like what Rachael here got ?? when you put in 31 its wrong and says its 32, so you put that in and its wrong again and goes to 33 and on and on..???... c'mon guys fix the glitch!

Yves Roulin
Yves Roulin
4,452 Points

Dont forget Arrays are 0 index, and 1 means 0, 2 means 1, 3 means 2 etc...

Maybe that can help someone here.

Thanks

Jason Mc Dermott
Jason Mc Dermott
11,496 Points

Thanks Yves I'm more've a HTML CSS guy but I'm getting the ropes..slowly ;)

Yves Roulin
Yves Roulin
4,452 Points

We all are learning, and thanks! Im glad i could help you! :D