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 trialixtepec
19,347 PointsFRONT END WEB DEVELOPMENT
- Code Challenge: Getting & Setting
Challenge task 2 of 2 On about line 18, set the 31st element in 'myArray' to the word 'treehouse'.
<script>
var myArray = ["sugar", "rush", "fix", "it", 3.14, 42];
var thirdElementInArray = myArray[2];
var myArray[30] = "treehouse";
</script>
When I submit the above code I get this message:
Oops! It looks like Task 1 is no longer passing. I didn't changed anything from the previous task!
1 Answer
James Barnett
39,199 PointsHere's your issue:
var myArray[30] = "treehouse";
You already declared myArray
you don't want to re-declare it using var
you want to assign a new value, so in this case the var
keyword throws a syntax error.
ixtepec
19,347 Pointsixtepec
19,347 PointsThanks James!!
Sometimes the obvious is "ignored". Lesson learned!!
Thanks again for your help.