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 trialmalik harden
149 PointsCan't log array
var snacks = ["chips", "pop", "salsa"];
console.log(snacks[2]);
trying to log the 3rd item should be simple but I'm struggling new to javascript sorry. everything online says I'm doing it properly plz help
var snacks = ["chips", "pop", "salsa"];
console.log(snacks[2]);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Arrays</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
Steven Parker
231,236 PointsIt looks like you might have tasks 2 and 3 mixed up. As Brendan pointed out, task 2 was to log the first item. And task 3 is to show the third item, but by using the alert function.
But there's also this warning given by every challenge: "Important: In each task of this code challenge, the code you write should be added to the code from the previous task.". So the work you do for task 2 should remain as-is when you write the code for task 3 on a separate line.
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsChallenge 2 or 3 was to print out the 1st item. Challenge 3 of 3 is to use the alert
function to show the 3rd item.
malik harden
149 Pointsmalik harden
149 Pointsthanks I was moving to fast and missed the part about keeping previous work thanks